List of usage examples for org.openqa.selenium By linkText
public static By linkText(String linkText)
From source file:$.RegisterFT.java
License:Apache License
@Test public void register() { // /*from w w w. j av a 2 s.c om*/ s.open("/logout"); s.click(By.linkText("")); s.type(By.id("loginName"), "user2"); s.type(By.id("name"), "Kevin"); s.type(By.id("plainPassword"), "user2"); s.type(By.id("confirmPassword"), "user2"); s.click(By.id("submit_btn")); // s.waitForTitleContains(""); assertThat(s.getValue(By.name("username"))).isEqualTo("user2"); s.type(By.name("password"), "user2"); s.click(By.id("submit_btn")); // ? s.waitForTitleContains("?"); // s.open("/logout"); }
From source file:$.TaskGuiFT.java
License:Apache License
/** * //?/.// ww w . j av a 2 s. c o m */ @Test @Category(Smoke.class) public void crudTask() { s.open("/task/"); // create s.click(By.linkText("")); Task task = TaskData.randomTask(); s.type(By.id("task_title"), task.getTitle()); s.click(By.id("submit_btn")); assertThat(s.isTextPresent("?")).isTrue(); // update s.click(By.linkText(task.getTitle())); assertThat(s.getValue(By.id("task_title"))).isEqualTo(task.getTitle()); String newTitle = TaskData.randomTitle(); s.type(By.id("task_title"), newTitle); s.click(By.id("submit_btn")); assertThat(s.isTextPresent("?")).isTrue(); // search s.type(By.name("search_LIKE_title"), newTitle); s.click(By.id("search_btn")); assertThat(s.getTable(By.id("contentTable"), 0, 0)).isEqualTo(newTitle); // delete s.click(By.linkText("")); assertThat(s.isTextPresent("?")).as("??").isTrue(); }
From source file:$.TaskGuiFT.java
License:Apache License
@Test public void inputInValidateValue() { s.open("/task/"); s.click(By.linkText("")); s.click(By.id("submit_btn")); assertThat(s.getText(By.xpath("//fieldset/div/div/span"))).isEqualTo(""); }// w w w . ja v a 2s. c om
From source file:AQ.TeamsUnitTest.java
@Test public void hello() { WebDriver driver = webDriver;//from ww w. j a v a 2s . com int noTeams = 3; driver.get(baseUrl + "/champgen/faces/index.xhtml"); driver.findElement(By.linkText("Login")).click(); driver.findElement(By.id("login-form:username")).sendKeys("admin"); driver.findElement(By.id("login-form:password")).sendKeys("admin"); driver.findElement(By.id("login-form:btnSubmit")).click(); driver.findElement(By.linkText("New Championship")).click(); driver.findElement(By.id("new-championship-form:name")).clear(); driver.findElement(By.id("new-championship-form:name")).sendKeys("TestChamp1"); driver.findElement(By.id("new-championship-form:btnSubmit")).click(); assertTrue(driver.findElement(By.id("msg:info")).getText().matches("^[\\s\\S]*added ![\\s\\S]*$")); for (int i = 0; i < noTeams; i++) { driver.findElement(By.linkText("New Team")).click(); driver.findElement(By.id("newteam-form:team")).clear(); driver.findElement(By.id("newteam-form:team")).sendKeys("Team" + i); driver.findElement(By.id("newteam-form:leader")).clear(); driver.findElement(By.id("newteam-form:leader")).sendKeys("Leader" + i); driver.findElement(By.id("newteam-form:btnSubmit")).click(); } this.pause(TIME_TO_PAUSE); this.pause(TIME_TO_PAUSE); driver.get(baseUrl + "/champgen/faces/index.xhtml"); int rowCount = webDriver.findElements(By.xpath("//table/tbody/tr")).size(); System.out.println(rowCount); assertTrue(rowCount == noTeams + 1); // + 1 because title is counted as row this.pause(TIME_TO_PAUSE); }
From source file:beseenium.model.action.findElementsBy.FindElementsByLinkTxt.java
License:Open Source License
/** * performs the find elements by link text action. * @param n the index of the element to find information on, i.e. if 3 results are found * the 0 will be the first element 1 the second and so on. will get an array out of bounds. * If you wish the action to return all of the results found then set n = -1. * @return String representation of the returnParam set in the ActionData object * passed into the constructor.//from w ww . jav a2s .co m * @throws ActionDataException */ @Override public String execute(int n) throws ActionDataException { String searchParam = super.context.getInputParam(); WebDriver browser = super.context.getDriver(); List<WebElement> htmlElements = browser.findElements(By.linkText(searchParam)); super.context.setElement(htmlElements); return FormatOutput.formatFindElementOutput(htmlElements, n); }
From source file:bingbot.BingBot.java
public void searchMobile(int m, int n, File file) throws Exception { System.out.println("Search method entered..."); scanner = new Scanner(file); Scanner sc = new Scanner(new File("./files/dict")); String next = scanner.next(); String name = null;/*from www . ja va 2 s. c o m*/ String password = null; while (!next.equals("END")) { name = next; password = scanner.next(); next = scanner.next(); } for (int k = 0; k < m; k++) { driver.get("http://live.com"); try { WebElement signout = driver.findElement(By.linkText("Sign out")); signout.click(); } catch (Exception e) { System.out.println("NO SUCH ELEMENT 'C_SIGNOUT'"); System.out.println("SIGNING IN"); } WebElement username = driver.findElement(By.id("i0116")); username.sendKeys(name); WebElement userpassword = driver.findElement(By.id("i0118")); userpassword.sendKeys(password); WebElement signin = driver.findElement(By.id("idSIButton9")); signin.click(); for (int j = 0; j < 41238; j++) { String word = sc.next(); list[j] = word; } for (int i = 0; i < n; i++) { Random rand = new Random(); driver.get("https://bing.com/"); WebElement query = driver.findElement(By.id("sb_form_q")); query.sendKeys(list[rand.nextInt(41238)]); WebElement go = driver.findElement(By.id("sbBtn")); go.click(); Thread.sleep(rand.nextInt(5000) + 5000); } } seleniumServer.stop(); }
From source file:br.gov.frameworkdemoiselle.behave.runner.webdriver.util.ByConverter.java
License:Open Source License
public static By convert(ElementLocatorType type, String locator) { By by = null;//from ww w. j av a 2s . c o m if (type == ElementLocatorType.Id) { by = By.id(locator); } else if (type == ElementLocatorType.ClassName) { by = By.className(locator); } else if (type == ElementLocatorType.CssSelector) { by = By.cssSelector(locator); } else if (type == ElementLocatorType.LinkText) { by = By.linkText(locator); } else if (type == ElementLocatorType.Name) { by = By.name(locator); } else if (type == ElementLocatorType.TagName) { by = By.tagName(locator); } else if (type == ElementLocatorType.XPath) { by = By.xpath(locator); } else if (type == ElementLocatorType.Value) { by = By.xpath("//*[@value='" + locator + "']"); } else { throw new BehaveException(message.getString("exception-invalid-option", type, "convert")); } return by; }
From source file:bst.cpo.automation.dm.actions.Settings_Actions.java
public void System_Overview_Click() { //TODO - Only available for BA users, add logic //app1/cpo/#/settings/system-overview logThis("Nav: Settings > System Overview"); WebElement element = DMDriver.findElement(By.linkText("System overview")); element.click();//from w w w . j av a2 s .c o m Assert.assertTrue(homeAction.Get_Main_Header().contains("System overview"), "Failed - Navigation to 'System overview'"); }
From source file:bst.cpo.automation.dm.actions.Settings_Actions.java
public void Sync_Computers_Click() { //app1/cpo/#/settings/sync logThis("Nav: Settings > Sync Computers"); WebElement element = DMDriver.findElement(By.linkText("Sync Computers")); element.click();/*from w w w.ja va2s .c om*/ Assert.assertTrue(homeAction.Get_Main_Header().contains("Sync computers"), "Failed - Navigation to 'Sync computers'"); }
From source file:bst.cpo.automation.dm.actions.Settings_Actions.java
public void Meeting_Room_Connector_Click() { //app1/cpo/#/settings/iwb //TODO - Only available for BA users, add logic logThis("Nav: Settings > Meeting Room Connector"); WebElement element = DMDriver.findElement(By.linkText("Meeting Room Connector")); element.click();/* ww w. j a v a 2s . c o m*/ Assert.assertTrue(homeAction.Get_Main_Header().contains("Meeting Room Connector"), "Failed - Navigation to 'Meeting Room Connector'"); }