After whole lot of search for many days I am asking for help here.
We have a setup where we are using javascript + selenium(webdriverjs).
We want to pass data in the browser which is opened via selenium. putting it simply, we want to execute any kind of javascript in the browser.
In java+selenium, we have JavaScriptExecutor class which does this thing. In javascript+selenium I am not able to find any thing similar to it.
I have experimented with driver.executeJavaScript and driver.executeScript. But that does not work.
Please help.
Note: I can't use protractor in my project.
1 Answer 1
here you go an example protractor
browser.executeScript('window.scrollTo(0,0);');
async execution
browser.executeAsyncScript('window.scrollTo(0,0);');
for webdriver js or other framework try with
driver.executeScript()
3 Comments
const promise = driver.get('https://google.co.in/'); promise.then(function() { driver.executeScript('window.abc="pramod";'); } After I removed it from promise and moved it above promise then it started working.Explore related questions
See similar questions with these tags.