Run existing function by selenium-webdriver's 'executeScript' method

1

I'm trying to run a function in the browser that is already set, but it is marked as undefined .

I ran the following code to reproduce the problem:

const webdriver = require("selenium-webdriver")
const driver = new webdriver.Builder().forBrowser("firefox").build()

driver.navigate().to("http://localhost/site")
driver.sleep(3000)

const code = 'console.log(window.sayHello)'
const logCode = 'console.log("${code}")'

driver.executeScript(logCode)
driver.executeScript(code)

When I tried to execute the same code - console.log(window.sayHello) - directly in the browser still open, it returned the desired function, as in the image:

EDITED

Thisseemstobeaspecificbugwiththefirefoxdriverbecausewiththechromeitworked.Ibelievethevariablewindowisbeingoverwritten overwrite , but I was not able to rewrite it with the% original%.

    
asked by anonymous 28.04.2017 / 23:01

0 answers