Webdriver | Execute JavaScript Using Testmate

JavaScript is one of the most preferred language used in web browsers. A browser has JavaScript implementation in it and interprets the JavaScript commands. WebDriver gives you an ability to executes the JavaScript in context of the loaded browser page. The Testmate code to execute JavaScript is as below:

1
2
3
4
5
6
7
8
9
10
11
'Initialize the driver
 Call wd.InitializeFireFoxDriver("C:\Users\Desktop\selenium")
 
'Navigate to the desired URL
 Call wd.NavigateToUrl("https://www.google.com/")
 
'Execute javascript
 Call wd.ExecuteScript("name::q","arguments[0].style.border='3px solid red'")
 
'Return page title using java script
 Msgbox wd.ExecuteScript("return document.title")

Add a Comment

Your email address will not be published. Required fields are marked *