March 21, 2018
Webdriver | Execute JavaScript Using Testmate
Warning: WP_Syntax::substituteToken(): Argument #1 ($match) must be passed by reference, value given in /home/pkq2w3icktox/public_html/wp-content/plugins/wp-syntax/wp-syntax.php on line 383
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") |