Some time it is necessary to add some more functionality in selenium. This can be achieved by extending user-extensions.js file.
For Ex. You want to add a method in selenium which shows a alert box.
To do this follow steps :
- Go to your server jar
- Open in winrar
- Goto core/scripts and edit user-extensions.js file
- Add Selenium.prototype.doAlert =function()
- {
- alert('hello');
- }
- Save and close the file.
- Start the server with -userExtensions switch
- i.e java -jar selenium-server-standalone-2.24.1.jar -userExtensions user-extensions.js
void fun()
{
HttpCommandProcessor http=new HttpCommandProcessor("localhost", 4444, "*iexplore", "http://www.google.com");
sel=new DefaultSelenium(http);
sel.start();
sel.open("/");
http.doCommand("alert", null); //This line executes alert method.
}
No comments:
Post a Comment