Open a URL in selenium
In this script we have open my blog and then clicked on a blog using its Xpath.Then we have added implicit wait for 5 sec then we have clicked on home by again getting its Xpath using firebug.import java.util.Properties;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class blogopen{
public static void main(String[] args) {
String base="https://seleniumtestingcom.blogspot.com";
WebDriver driver=new FirefoxDriver();
driver.get(base);
driver.findElement(By.xpath("/html/body/div[4]/div[2]/div[2]/div[2]/div[2]/div[2]/div[2]/div/div[4]/div[1]/div/div/div/div[1]/div[1]/div/div[2]/div/h3/a")).click();
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
driver.findElement(By.xpath("/html/body/div[3]/div[2]/div[2]/div[2]/div[2]/div[2]/div[2]/div/div[4]/div[1]/div/div/div/div[2]/a")).click();
driver.close();
}
}
0 comments: