Install firebug add on to Firefox browser then (
if you are using Firefox as Ur browser)
Install firepath add on ( for finding xpath of an
element)
Above two things make us to identify elements very
easily in a web page, almost like object spy in QTP.
Firebug: firebug is a
add on of Firefox which is used for inspecting the web elements in the web
application and knowing the information about them.
Firepath: firepath is a
add on of Firefox which is used for specially showing the xpath of a web
element.
Xpath: xpath is a
unique locator of a web element in a webpage.
Navigation for firebug in the Firefox:
Open Firefox browser
Activate menu item tools
Go to web developers then
Go to firebug
Click on open firebug
To avoid above navigation press f12 we can
directly open firebug.
package pack1;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import
org.openqa.selenium.firefox.FirefoxDriver;
public class web {
public static void main(String[] args) {
WebDriver wd =new FirefoxDriver();
wd.get("http:yahoomail.com");
wd.findElement(By.xpath(".//*[@id='username']")).sendKeys("akhilreddyhyd@yahoo.com");
wd.findElement(By.xpath(".//*[@id='passwd']")).sendKeys("venkannaAAA143");
wd.findElement(By.xpath(".//*[@id='.save']")).click();
}
}
Write a java program to demonstrate
selenium webdriver:
FIRST SELENIUM PROGRAMME:
package aa;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class a {
public static void main(String[] args) throws InterruptedException {
WebDriver wd= new FirefoxDriver();
wd.get("http:gmail.com");
wd.findElement(By.xpath(".//*[@id='Email']")).sendKeys("akhilreddyhydAAAA@gmail.com");
wd.findElement(By.xpath(".//*[@id='Passwd']")).sendKeys("venkanna143");
wd.findElement(By.xpath(".//*[@id='signIn']")).click();
Thread.sleep(5000);
wd.findElement(By.xpath(".//*[@id=':b7']/div/div")).click();
Thread.sleep(5000);
wd.findElement(By.xpath(".//*[@id=':14i']")).sendKeys("akhilreddyhyd@gmail.com");
wd.findElement(By.xpath(".//*[@id=':161']")).sendKeys("Hi
h r u");
wd.findElement(By.xpath(".//*[@id=':16i']")).click();
Thread.sleep(5000);
wd.findElement(By.xpath(".//*[@id='gbgs4d']/span[2]")).click();
wd.findElement(By.xpath(".//*[@id='gb_71']")).click();
}
}
WAY2SMS.COM
public class way {
public static void main(String[] args) {
WebDriver wd=new FirefoxDriver();
wd.get("http://site3.way2sms.com/content/index.html");
wd.findElement(By.xpath(".//*[@id='username']")).sendKeys("9440592994");
wd.findElement(By.xpath(".//*[@id='password']")).sendKeys("XXXXXXX");
wd.findElement(By.xpath(".//*[@id='button']")).click();
}
}
No comments:
Post a Comment