List of usage examples for org.openqa.selenium By id
public static By id(String id)
From source file:testTheClient.java
@Test public void zCreateNewCarEntry() throws Exception { (new WebDriverWait(driver, WAIT_MAX)).until((ExpectedCondition<String>) (WebDriver d) -> { return d.findElement(By.xpath("//*[@id=\"new\"]")).getText(); });/* w ww. ja v a 2 s . c om*/ //populate fields driver.findElement(By.id("new")).click(); driver.findElement(By.id("year")).sendKeys("2008"); driver.findElement(By.id("registered")).sendKeys("2002-5-5"); driver.findElement(By.id("make")).sendKeys("Kia"); driver.findElement(By.id("model")).sendKeys("Rio"); driver.findElement(By.id("description")).sendKeys("As new"); driver.findElement(By.id("price")).sendKeys("31000"); //save driver.findElement(By.id("save")).click(); List<WebElement> updatedRows = (new WebDriverWait(driver, WAIT_MAX)) .until((ExpectedCondition<WebElement>) (WebDriver d) -> { return d.findElement(By.tagName("tbody")); }).findElements(By.tagName("tr")); assertThat(updatedRows.size(), is(6)); assertThat(updatedRows.get(5).findElements(By.tagName("td")).get(1).getText(), is("2008")); assertThat(updatedRows.get(5).findElements(By.tagName("td")).get(4).getText(), is("Rio")); }
From source file:WebTestSelenium5.java
public void testTagNameById() { assertEquals(driver.findElement(By.id("footer")).getTagName(), "div"); }
From source file:WebTestSelenium5.java
public void testAttribute() { assertEquals(driver.findElement(By.id("header")).getAttribute("alt"), null); }
From source file:WebTestSelenium5.java
public void testIsEnabled() { assertEquals(driver.findElement(By.id("google")).isEnabled(), true); }
From source file:WebTestSelenium5.java
public void testIsSelected() { assertEquals(driver.findElement(By.id("google")).isSelected(), true); }
From source file:AddTask.java
@Test public void testAddTask() throws Exception { driver.get(baseUrl + "/LoginWebApp/taskPage.jsp?username=admin"); driver.findElement(By.xpath("(//button[@type='button'])[2]")).click(); driver.findElement(By.id("tasktitle")).clear(); driver.findElement(By.id("tasktitle")).sendKeys("teste"); driver.findElement(By.id("taskmessage")).clear(); driver.findElement(By.id("taskmessage")).sendKeys("teste"); driver.findElement(By.id("date")).clear(); driver.findElement(By.id("date")).sendKeys("03/05/2010"); driver.findElement(By.xpath("(//button[@type='button'])[4]")).click(); assertEquals("Task successfully added!", closeAlertAndGetItsText()); }
From source file:ForumTestSelenium.java
@Test public void testForumselenium() throws Exception { driver.get(baseUrl + "/forum/"); driver.findElement(By.id("btToCadastro")).click(); driver.findElement(By.name("nome")).clear(); driver.findElement(By.name("nome")).sendKeys("Julio Valsesia"); driver.findElement(By.name("login")).clear(); driver.findElement(By.name("login")).sendKeys("jvalsesia"); driver.findElement(By.name("email")).clear(); driver.findElement(By.name("email")).sendKeys("jvalsesia@email.com"); driver.findElement(By.name("senha")).clear(); driver.findElement(By.name("senha")).sendKeys("1234"); driver.findElement(By.id("btCadastrar")).click(); driver.findElement(By.name("login")).clear(); driver.findElement(By.name("login")).sendKeys("jvalsesia"); driver.findElement(By.name("senha")).clear(); driver.findElement(By.name("senha")).sendKeys("1234"); driver.findElement(By.id("btLogin")).click(); driver.findElement(By.id("btInserirTopico")).click(); driver.findElement(By.name("titulo")).clear(); driver.findElement(By.name("titulo")).sendKeys("topico 01"); driver.findElement(By.name("conteudo")).clear(); driver.findElement(By.name("conteudo")).sendKeys("conteudo 01"); driver.findElement(By.id("btNewTopico")).click(); driver.findElement(By.id("btExibir")).click(); driver.findElement(By.name("comentario")).clear(); driver.findElement(By.name("comentario")).sendKeys("comentario 01"); driver.findElement(By.id("btNovoComentario")).click(); driver.findElement(By.id("btVoltaTopicos")).click(); driver.findElement(By.id("btExibir")).click(); driver.findElement(By.id("btVoltaTopicos")).click(); driver.findElement(By.id("btExibirRanking")).click(); driver.findElement(By.id("btVoltaTopicos")).click(); }
From source file:ClientServicesQA.java
public void loginToClientServices(String url, WebDriver driver) throws InterruptedException { String institutionName = "Client Services"; String userName = "MHCampusAutomationAdmin"; String password = "12345678"; driver.manage().window().maximize(); driver.get(url);/*from w w w. j a v a 2s . c o m*/ driver.findElement(By.id("TextBoxInstitution")).clear(); // clearing the institution text box driver.findElement(By.id("TextBoxInstitution")).sendKeys(institutionName); // enter institution name driver.findElement(By.id("TextBoxUsername")).clear(); // enter user name driver.findElement(By.id("TextBoxUsername")).sendKeys(userName);// clearing the user name text box driver.findElement(By.id("TextBoxPassword")).clear(); // enter password driver.findElement(By.id("TextBoxPassword")).sendKeys(password);// clearing the password text box driver.findElement(By.id("ButtonLogin")).click(); //Clicking on the Login button Thread.sleep(2000); //driver.findElement(By.partialLinkText("Convert")).click(); // find element by partial text //driver.findElement(By.id("ctl00_LoginStatus1")).click(); driver.close(); }
From source file:inclass2test.java
@Test public void testHasSearchBox() { WebElement search = driver.findElement(By.id("search")); assertTrue(search != null); }
From source file:NewCarTest.java
public void shouldWaitForPageToLoad() { WebDriverWait wait = new WebDriverWait(driver, 10); wait.until(ExpectedConditions.presenceOfElementLocated(By.id("tbodycars"))); }