Sometimes, when testing web applications, there arises a need to launch some script on the page.
The easiest way to do so is launching the script directly from the address bar of the browser.
To launch the script in the browser, it is necessary to:
var br = Aliases.browser; br.ToUrl("http://smartbear.com"); var page = br.pageMain;
page.NavigateTo("javascript: alert('A message from script'),");
To execute the JavaScript code in the browser window, it is sufficient to input the code into the address bar of the browser as a string, placing the keyword javascript:
before the pasted code.
The method NavigateTo
lets us open the page specified by the URL
parameter. Unlike the ToUrl
method, method NavigateTo
doesn't return any value after the page is loaded.
In our case, the method of NavigateTo
is used to execute the JavaScript code on the page.
18.118.32.222