Here is a simple program that shows how to use selenium.
More concrete examples of webdriver/selenium and page-objects are at http://code.google.com/p/java-through-examples/source/browse/tests/org/megha/blog/example/selenium/
More concrete examples of webdriver/selenium and page-objects are at http://code.google.com/p/java-through-examples/source/browse/tests/org/megha/blog/example/selenium/
package org.megha.blog.example.selenium; |
import com.thoughtworks.selenium.DefaultSelenium; |
import com.thoughtworks.selenium.Selenium; |
/** |
* Searches for a given string on yahoo.com. |
* (just an example to show how selenium client is used.) |
*/ |
public class YahooSearch { |
// searches for the given string and prints the top two results |
public void searchFor(String string) { |
Selenium selenium = new DefaultSelenium("LOCALHOST", 4444, "*firefox", "http://www.yahoo.com/"); |
selenium.start(); |
selenium.open("/"); |
selenium.waitForPageToLoad("30000"); |
selenium.type("name=p", string); |
selenium.click("id=search-submit"); |
selenium.waitForPageToLoad("30000"); |
// TODO: do something with the results |
selenium.close(); |
selenium.stop(); |
} |
public static void main(String[] args) { |
YahooSearch search = new YahooSearch(); |
search.searchFor("google"); |
} |
} |
Good short and simple example... Thank you...
ReplyDeletePlease find the below useful link which provides selenium webdriver tutorials which will also guide you to build a good framework.
http://seleniumeasy.com
Thanks Dev Hari for sharing the above URL
ReplyDeleteSelenium Tutorials Really helped me.