List of usage examples for org.openqa.selenium By id
public static By id(String id)
From source file:WebTestSelenium11.java
public void testTagNameById() { assertEquals(driver.findElement(By.id("omega-media-query-dummy")).getTagName(), "img"); }
From source file:WebTestSelenium11.java
public void testAttribute() { assertEquals(driver.findElement(By.id("omega-media-query-dummy")).getAttribute("alt"), "gil fried"); }
From source file:WebTestSelenium11.java
public void testIsEnabled() { assertEquals(driver.findElement(By.id("omega-media-query-dummy")).isEnabled(), true); }
From source file:WebTestSelenium11.java
public void testIsSelected() { assertEquals(driver.findElement(By.id("omega-media-query-dummy")).isSelected(), false); }
From source file:SearchTest.java
@Test public void test() throws InterruptedException { driver.get(baseUrl + "/samplecenter/faces/index.xhtml"); driver.findElement(By.id("j_idt11:searchbar")).clear(); driver.findElement(By.id("j_idt11:searchbar")).sendKeys("yolo"); Thread.sleep(1000);// w w w.ja v a2 s . c o m driver.findElement(By.name("j_idt11:j_idt12")).click(); Thread.sleep(1000); assertEquals("1 results", driver.findElement(By.id("resultcount")).getText()); }
From source file:ExperimentRunner.java
License:Apache License
protected void runExperiment(String url, Hashtable<String, ArrayList<String>> store) { driver.get(url);// www. ja v a 2 s . c o m // for octane, if an element with id="jit_final_result" contains text "===experiment done===" new WebDriverWait(driver, maxWaitTime).until(ExpectedConditions .textToBePresentInElementLocated(By.id("jit_final_result"), "===experiment done===")); System.out.println("text found in element"); String expResult = driver.findElement(By.id("jit_final_result")).getAttribute("innerHTML"); System.out.println(expResult); processRecordConsoleOutput(expResult, store); }
From source file:CakeHomePageTest.java
@Test public void software() throws IOException { //WebElement button = driver.findElement(By.linkText("/pricing/")); clickNavElm("Software"); WebElement button = driver.findElement(By.id("have-taste-btn")); button.click();/*from w w w . j a v a 2s.c o m*/ List<WebElement> elements = driver.findElements(By.cssSelector(".entry-title")); Boolean isRightPage = false; for (WebElement element : elements) { if ("Insights delivered to your dashboard at the touch of a button.".equals(element.getText())) { isRightPage = true; } } if (!isRightPage) { fail("Not on the right page!"); } }
From source file:facets_testing.java
public void wp_login() { WebDriver driver = new ChromeDriver(); try {//from ww w . j av a2s . c om driver.get(wordpress_url); driver.findElement(By.id("user_login")).sendKeys(username); driver.findElement(By.id("user_pass")).sendKeys(password); driver.findElement(By.id("wp-submit")).click(); } catch (Exception e) { System.out.println("Exception produced when logging into wp-admin. Error is: " + e); } }
From source file:ExpiredLicenseSelenium.java
@Test public void testAddLicenseWebDriver() throws Exception { Date now = new java.util.Date(); String ts = new Timestamp(now.getTime()).toString(); String validTill = addDays(now, 15); driver.get(baseUrl + "#/"); driver.findElement(By.linkText("Start licensing process")).click(); driver.findElement(By.id("nameOrganization")).clear(); driver.findElement(By.id("nameOrganization")).sendKeys(ts); driver.findElement(By.id("applicationArea")).clear(); driver.findElement(By.id("applicationArea")).sendKeys("ApplicationAreaTest"); driver.findElement(By.id("nameContact")).clear(); driver.findElement(By.id("nameContact")).sendKeys("NameTest"); driver.findElement(By.id("email")).clear(); driver.findElement(By.id("email")).sendKeys("email@test"); driver.findElement(By.id("skype")).clear(); driver.findElement(By.id("skype")).sendKeys("SkypeTest"); driver.findElement(By.id("phone")).clear(); driver.findElement(By.id("phone")).sendKeys("PhoneTest"); driver.findElement(By.cssSelector("div.form-group > button.btn.btn-default")).click(); new Select(driver.findElement(By.id("product"))).selectByVisibleText("i-Voting 11.2"); driver.findElement(/* ww w . j a v a 2s . c o m*/ By.cssSelector("form[name=\"chooseProductForm\"] > div.form-group > button.btn.btn-default")) .click(); driver.findElement(By.id("validFrom")).clear(); driver.findElement(By.id("validFrom")).sendKeys("1900-01-01"); driver.findElement(By.id("validTill")).clear(); driver.findElement(By.id("validTill")).sendKeys(validTill); driver.findElement(By.id("addLicenseSubmit")).click(); //Check if license is expiring driver.findElement(By.xpath("//div[@id='bs-example-navbar-collapse-1']/ul[2]/li[2]/a/span/i[2]")).click(); //TODO Add a check based on id instead of validFrom/validTill dates List<WebElement> list = driver.findElements(By.xpath("//*[contains(text(),'" + "1900-01-01" + "')]")); Assert.assertTrue("License not found!", list.size() > 0); List<WebElement> list2 = driver.findElements(By.xpath("//*[contains(text(),'" + validTill + "')]")); Assert.assertTrue("License not found!", list2.size() > 0); }
From source file:EditTask.java
@Test public void testEditTask() throws Exception { driver.get(baseUrl + "/LoginWebApp/taskPage.jsp?username=admin"); driver.findElement(By.xpath("//button[@onclick='editTask(this)']")).click(); driver.findElement(By.id("taskmessage1")).clear(); driver.findElement(By.id("taskmessage1")).sendKeys("ola"); driver.findElement(By.xpath("(//button[@type='button'])[7]")).click(); assertEquals("Task successfully Updated!", closeAlertAndGetItsText()); }