For this, open a command prompt and type:
java -jar C:\selenium-remote-control-1.0-beta-1\selenium-server-1.0-beta-1\selenium-server.jar -interactive
The window will look something like this:
Let's begin by using Selenium Server to open up a browser. If you're on Windows and want to run your Selenium commands using Internet Explorer, try typing this:
cmd=getNewBrowserSession&1=*iexplore&2=http://www.google.com
If you want to use Firefox, try this:
command: "getNewBrowserSession"
cmd=getNewBrowserSession&1=*firefox&2=http://www.google.com
browser: (*iexplore for Internet Explorer, *firefox for Firefox, or *opera for Opera)
url: www.google.com.
On Execution of the above command: an HTTP web requests to the Selenium Server, requesting work to be done.
Note: In non-interactive mode, you can use any automated tool you like to send these HTTP requests to the server, instead of typing them by hand.
---> Requesting http://localhost:4444/selenium-server/driver?cmd=getNewBrowserSession&1=*firefox&2=http://www.google.com
I
f all goes well, you should see a new browser window starting with the browser of your choice. Back in the Selenium Server command window, you should see the following message:
Got result: OK,
on session
cmd=open&1=http://www.google.com/webhp&sessionId=
When this command finishes, your browser window should reveal google.com in the lower frame. (The /webhp makes sure we stay on www.google.com; otherwise, we might get redirected to a country-specific Google server, e.g., www.google.co.in) Don't forget that you need to replace the Session ID above with your own personal Session ID, the one you got when you ran the "getNewBrowserSession" command.
Now that Google is open, let's try typing something in the search box. Type this in the Selenium Server command window:
cmd=type&1=q&2=hello world&sessionId=
Now, let's do a search!
cmd=click&1=btnG&sessionId=85b346a408e748309860563acfc95754
You should now see the results of your Google Search in your browser window. You can run dozens of Selenium commands to automate all manner of browsing tasks. For more information on particular commands, you can go look at the Selenium Core section at the Open QA website, or check out the reference materials available for any of our Client Drivers (Java, .NET, Perl, PHP, Python or Ruby).
The next thing we might want to do is read some information back out of the page... for example, let's retrieve the HTML title of the current page, like this:
cmd=getTitle&sessionId=85b346a408e748309860563acfc95754
The browser will return the title of the HTML page we've loaded, like this:
Got result: OK,hello world - Google Search on session 85b346a408e748309860563acfc95754
That's enough Interactive Mode for now; let's move on to writing some code! But before we go, let's stop the browser we started. Type this command in the Selenium Server command window:
cmd=testComplete&sessionId=85b346a408e748309860563acfc95754
When this command finishes, your browser window should automatically close. To quit the Selenium Server, type "quit" or just press Ctrl-C.
No comments:
Post a Comment