List of usage examples for org.openqa.selenium By linkText
public static By linkText(String linkText)
From source file:com.jpablo.test.NavigateWikipedia.java
public void doAnotherSearchFF(String sendKeys1, String sendKeys2) throws InterruptedException { /*/*from w w w . j a v a 2 s . c o m*/ 1. Launch Firefox explorer 2. Open Wikipedia main page 3. Open Wikipedia in English 4. Type a word to search 5. Click on Search button 6. Open Wikipedia in Spanish 7. Type another word to search 8. Click on Search button 9. Close Firefox */ driver = new FirefoxDriver(); driver.get("http://www.wikipedia.org"); link = driver.findElement(By.linkText("English")); link.click(); Thread.sleep(10000); searchBox = driver.findElement(By.id("searchInput")); searchBox.sendKeys(sendKeys1); searchBox.submit(); Thread.sleep(5000); link = driver.findElement(By.linkText("Espaol")); link.click(); Thread.sleep(10000); searchBox = driver.findElement(By.id("searchInput")); searchBox.sendKeys(sendKeys2); searchBox.submit(); Thread.sleep(5000); driver.quit(); }
From source file:com.jpablo.test.NavigateWikipedia.java
public void openWikiEnglishIE() throws InterruptedException { /*/*w w w . ja v a 2 s. c o m*/ 1. Launch IE 2. Open Wikipedia main page 3. Open Wikipedia in English 4. Close IE */ System.setProperty("webdriver.ie.driver", "C:\\SeleniumUtilities\\IEDriverServer.exe"); driver = new InternetExplorerDriver(); driver.get("http://www.wikipedia.org"); link = driver.findElement(By.linkText("English")); link.click(); Thread.sleep(5000); driver.quit(); }
From source file:com.jpablo.test.NavigateWikipedia.java
public void openWikiEnglishChrome() throws InterruptedException { /*/* www .ja va2 s. co m*/ 1. Launch Chrome 2. Open Wikipedia main page 3. Open Wikipedia in English 4. Close Chrome */ System.setProperty("webdriver.chrome.driver", "C:\\SeleniumUtilities\\chromedriver.exe"); driver = new ChromeDriver(); driver.get("http://www.wikipedia.org"); link = driver.findElement(By.linkText("English")); link.click(); Thread.sleep(5000); driver.quit(); }
From source file:com.jpablo.test.NavigateWikipedia.java
public void doSearchWikiENIE(String sendKeys) throws InterruptedException { /*/*from w w w . j a va2 s. c om*/ 1. Launch IE 2. Open Wikipedia main page 3. Open Wikipedia in English 4. Type a word to search 5. Click on Search button 6. Close IE */ System.setProperty("webdriver.ie.driver", "C:\\IEDriverServer.exe"); driver = new InternetExplorerDriver(); driver.get("http://www.wikipedia.org"); link = driver.findElement(By.linkText("English")); link.click(); Thread.sleep(10000); searchBox = driver.findElement(By.id("searchInput")); searchBox.sendKeys(sendKeys); searchBox.submit(); Thread.sleep(5000); driver.quit(); }
From source file:com.jpablo.test.NavigateWikipedia.java
public void doSearchAutoSuggest(String sendKeys) throws InterruptedException { /*//ww w.j a va2s. c om 1. Launch Firefox explorer 2. Open Wikipedia main page 3. Open Wikipedia in English 4. Type a word to search 5. Compare the word to search vs the list elements */ driver = new FirefoxDriver(); driver.get("http://www.wikipedia.org"); link = driver.findElement(By.linkText("English")); link.click(); Thread.sleep(8000); searchBox = driver.findElement(By.id("searchInput")); searchBox.sendKeys(sendKeys); List<WebElement> optionsToSelect = driver.findElements(By.xpath("//div[@class='suggestions-result']")); System.out.println("Word to search: " + sendKeys); System.out.println("Size of Autosuggest is: " + optionsToSelect.size()); for (WebElement option : optionsToSelect) { System.out.println(""); System.out.println("Values are: \n" + option.getText()); System.out.println("Band " + option.getText().equals(sendKeys)); if (option.getText().equals(sendKeys)) { System.out.println("Selecting: " + sendKeys); option.click(); break; } } Thread.sleep(5000); driver.quit(); }
From source file:com.jpablo.test.NavigateWikipedia.java
public void doSearchAutoSuggestIndex(String sendKeys) throws InterruptedException { /*/* w ww. ja v a2s.c o m*/ 1. Launch Firefox explorer 2. Open Wikipedia main page 3. Open Wikipedia in English 4. Type a word to search 5. Compare the word to search vs the list elements */ int ind; driver = new FirefoxDriver(); driver.get("http://www.wikipedia.org"); link = driver.findElement(By.linkText("English")); link.click(); Thread.sleep(8000); searchBox = driver.findElement(By.id("searchInput")); searchBox.sendKeys(sendKeys); List<WebElement> optionsToSelect = driver.findElements(By.xpath("//div[@class='suggestions-result']")); System.out.println("Word to search: " + sendKeys); System.out.println("Size of Autosuggest is: " + optionsToSelect.size()); for (WebElement option : optionsToSelect) { System.out.println("Values are: \n" + option.getText()); System.out.println("Band " + option.getText().equals(sendKeys)); } ind = indice(optionsToSelect.size()); System.out.println("Index is " + ind); optionsToSelect.get(ind).click(); Thread.sleep(5000); driver.quit(); }
From source file:com.jpablo.test.NavigateWikipedia.java
public void doSearchWordsMap(List<String> wordList) throws InterruptedException { Map<String, String> map = new HashMap<String, String>(); driver = new FirefoxDriver(); driver.get("http://www.wikipedia.org"); link = driver.findElement(By.linkText("English")); link.click();//from w w w . j a v a2 s . c o m for (String cad : wordList) { map.put(cad, cad.toString()); System.out.println(map.get(cad)); Thread.sleep(8000); searchBox = driver.findElement(By.id("searchInput")); searchBox.sendKeys(map.get(cad)); searchBox.submit(); } Thread.sleep(5000); driver.quit(); }
From source file:com.jpablo.test.NavigateWikipedia.java
public void doSearchWordsMap2(Map<String, String> map) throws InterruptedException { Iterator<String> it = map.keySet().iterator(); driver = new FirefoxDriver(); driver.get("http://www.wikipedia.org"); link = driver.findElement(By.linkText("English")); link.click();// w w w .j a v a 2 s .c o m while (it.hasNext()) { String key = it.next(); System.out.println(map.get(key)); Thread.sleep(8000); searchBox = driver.findElement(By.id("searchInput")); searchBox.sendKeys(map.get(key)); searchBox.submit(); } Thread.sleep(5000); driver.quit(); }
From source file:com.jpablo.test.TestWikipediaFF.java
@Test public void openWikiEnglishFirefox() throws InterruptedException { /*//from w w w .j a va 2s .co m 1. Launch Firefox 2. Open Wikipedia main page 3. Open Wikipedia in English 4. Close Firefox */ driver.get(baseURL); link = driver.findElement(By.linkText("English")); link.click(); assertTrue(isElementPresent(By.linkText("English"))); }
From source file:com.jpablo.test.TutorialSelenium.java
public void testFirefox() throws InterruptedException { driver = new FirefoxDriver(); driver.get("http://www.wikipedia.org"); link = driver.findElement(By.linkText("English")); link.click();//from w w w . ja va 2s .c o m Thread.sleep(10000); /*partialLinkText = driver.findElement (By.partialLinkText("the Bank")); partialLinkText.click(); */ //Thread.sleep(10000); link = driver.findElement(By.linkText("Espaol")); link.click(); Thread.sleep(30000); linkText = driver.findElement(By.linkText("Software")); linkText.click(); Thread.sleep(10000); searchBox = driver.findElement(By.id("searchInput")); searchBox.sendKeys("Software"); searchBox.submit(); Thread.sleep(5000); driver.quit(); }