Selenium - Executescript passing variable Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
Axxi
Posts: 15
Joined: 02 Apr 2020, 10:56

Selenium - Executescript passing variable

23 May 2020, 13:59

Hi!

Im trying to replace "hello world" below with a variable, but I just cant find the way to do so, i always get an error probably because the code is just wrong.

driver.executeScript("arguments[0].setAttribute('value', 'hello world')", driver.FindElementsbyXpath("//input[@name='InvoiceItemNumber']"))

Does anyone have any exeperience with this being possible at all?


Thanks in advance!
User avatar
Xtra
Posts: 1833
Joined: 02 Oct 2015, 12:15

Re: Selenium - Executescript passing variable  Topic is solved

23 May 2020, 15:52

Code: Select all

var := "hello world"
element := driver.FindElementsbyXpath("//input[@name='InvoiceItemNumber']")
driver.executeScript("arguments[0].setAttribute('value', '" . var . "');", element)
Axxi
Posts: 15
Joined: 02 Apr 2020, 10:56

Re: Selenium - Executescript passing variable

24 May 2020, 06:33

Thank you so much, works like a charm. Much appreciated !



Xtra wrote:
23 May 2020, 15:52

Code: Select all

var := "hello world"
element := driver.FindElementsbyXpath("//input[@name='InvoiceItemNumber']")
driver.executeScript("arguments[0].setAttribute('value', '" . var . "');", element)

Return to “Ask For Help”

Who is online

Users browsing this forum: littlegandhi1199, tatagi and 36 guests