Try http://code.google.com/p/fire-ie-selenium/downloads
This is not an IDE , a simple utility to get the locators ( ID,Name,Xpath,TagName).
This is not an IDE , a simple utility to get the locators ( ID,Name,Xpath,TagName).
selenium.click("link=glob:*Gifts"); // Clicks on any link with text suffixed with 'Gifts' selenium.verifyTextPresent("glob:*Gifts*");
selenium.click("link=regexpi:^Over \\$[0-9]+$"); //matches links such as 'Over $75', 'Over $85' etc
selenium.highlight("//div[contains(@class,'cnn_sectbin')]"); //highlights the first div with class attribute that contains 'cnn_sectbin' selenium.highlight("css=div#cat_description:contains(\"to last\")"); //locating a div containing the text 'to last' using css selector
selenium.click("//img[starts-with(@id,'cat_prod_image')]"); //clicks on the first image that has an id attribute that starts with 'cat_prod_image' selenium.click("//div[starts-with(@id,'tab_dropdown')]/a[last()]"); //clicks on the last link within the div that has a class attribute starting with 'tab_dropdown' selenium.click("//div[starts-with(@id,'tab_dropdown')]/a[position()=2]"); //clicks on the second link within the div that has a class attribute starting with 'tab_dropdown' selenium.highlight("css=div[class^='samples']"); //highlights div with class that starts with 'samples'
selenium.highlight("css=div[class$='fabrics']"); //highlights div with class that ends with 'fabrics' selenium.click("//img[ends-with(@id,'cat_prod_image')]"); //clicks on the first image that has an id attribute that ends with 'cat_prod_image'
javascript:function getNode(node){var nodeExpr=node.tagName;if(!nodeExpr)return null;if(node.id!=''){nodeExpr+="[@id='"+node.id+"']";return "/"+nodeExpr;}var rank=1;var ps=node.previousSibling;while(ps){if(ps.tagName==node.tagName){rank++;}ps=ps.previousSibling;}if(rank>1){nodeExpr+='['+rank+']';}else{var ns=node.nextSibling;while(ns){if(ns.tagName==node.tagName){nodeExpr+='[1]';break;}ns=ns.nextSibling;}}return nodeExpr;}
Testcode:public class GooglePage extends MyDriver{ @FindBy(how = How.NAME, using = "q") private WebElement searchtext; public
GooglePage
() { super(); System.out.println("cool stuff!"); } public void typeText(){ searchtext.sendKeys("abc"); } }
public class TestCode{
public TestCode(){
GooglePage googlePage = PageFactory.initElements(driver, GooglePage.class);
//
We need to use PageFactory.initElements(driver, GooglePage.class)
// instead of "new GooglePage()
since the GooglePage defines the WebElement using @FindBy.
}
public void testCase1(){
googlePage.typeText();
....
}
}
Ref: http://openwritings.net/public/testng/ant-build-file-testng
version="1.0" encoding="UTF-8"?>
basedir="." default="runTestNG" name="Sample of Ant file for TestNG">
name="testng" classname="org.testng.TestNGAntTask">
>
location="lib/testng/testng-5.14.7.jar"/>
>
>
name="testng.output.dir" value="testng_output"/>
id="classes">
location="bin"/>
>
name="runTestNG">
dir="${testng.output.dir}"/>
outputdir="${testng.output.dir}" classpathref="classes">
dir="." includes="testng.xml"/>
>
>
>
name="testng_nice_report"> dir="testng_nice_report"/> in="testng_output/testng-results.xml" style="lib/testng-xslt-0.6.2/src/main/resources/testng-results.xsl" out="testng_nice_report/index.html"> name="testNgXslt.outputDir" expression="${basedir}/testng_nice_report"/> name="testNgXslt.showRuntimeTotals" expression="true"/> refid="MyClasspath"/> > >
http://bradjsimpson.blogspot.com/2010/09/generating-selenium-reports-using.html
public void inputValue(WebElement
txtbox
,String value) throws Exception{
txtbox
.sendKeys(Keys.chord(Keys.CONTROL, "a"), value);
}