Java examples for HTML:selenium
Find element from selenium firefox browser
import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; public class Usps { public static void main(String[] args) throws InterruptedException { //step 1 open web browser /* w w w .j a va 2s. c o m*/ WebDriver driver = new FirefoxDriver(); driver.get("https://www.your server.com/"); WebElement element1 = driver.findElement(By.xpath(".//*[@id='global-menu']/div/nav/ol/li[2]/a/span"));element1.click(); WebElement element2 = driver.findElement(By.xpath(".//*[@id='shortcuts-menu']/div[1]/div[3]/div[3]/a/span")); element2.click(); Thread.sleep(5000); // this is in millisecond WebElement element3 = driver.findElement(By.xpath(".//*[@id='tCityStateZip']")); element3.sendKeys("20878"); element3.submit(); driver.close(); } }