List of usage examples for org.openqa.selenium WebDriver get
void get(String url);
From source file:gov.nasa.jpl.memex.nutch.protocol.selenium.handlers.login.LoginHandler23.java
License:Apache License
public void processDriver(WebDriver driver) { if (driver.getTitle().equals("Access Denied / User Login | Slickguns")) { if (a.equals("http://www.slickguns.com/users/reviewer")) { // driver.get(a); driver.findElement(By.id("edit-name")).clear(); driver.findElement(By.id("edit-name")).sendKeys("//username"); driver.findElement(By.id("edit-pass")).clear(); driver.findElement(By.id("edit-pass")).sendKeys("//password"); driver.findElement(By.id("edit-submit")).click(); //after log in, again go back to the page we wanted to be in driver.get(a); } else if (a.equals("http://www.slickguns.com/users/glock-fan")) { // driver.get(domain + "/users/glock-fan"); driver.findElement(By.id("edit-name")).clear(); driver.findElement(By.id("edit-name")).sendKeys("//username"); driver.findElement(By.id("edit-pass")).clear(); driver.findElement(By.id("edit-pass")).sendKeys("password"); driver.findElement(By.id("edit-submit")).click(); //after log in, again go back to the page we wanted to be in driver.get(a);/*from w w w .ja v a 2 s . c om*/ } else { return; } } else { return; } }
From source file:gov.nasa.jpl.memex.nutch.protocol.selenium.handlers.login.LoginHandler32.java
License:Apache License
public void processDriver(WebDriver driver) { String OriginalURL = driver.getCurrentUrl(); driver.get(OriginalURL); //Find the login button and click on it WebElement LoginButton = driver.findElement(By.linkText("Login")); LoginButton.click();// w w w. j a va2s . c o m //Find the username textbox using the name of the textbox - which is typically "Username" WebElement useremail = driver.findElement(By.linkText("Username")); //if username is not found try finding an element with "email" if (null == useremail) { useremail = driver.findElement(By.linkText("email")); } useremail.clear(); useremail.sendKeys("cs572team32@gmail.com"); WebElement password = driver.findElement(By.linkText("Password")); password.clear(); password.sendKeys("ViewSonic"); WebElement submitButton = driver.findElement(By.linkText("submit")); submitButton.click(); }
From source file:gov.nasa.jpl.memex.nutch.protocol.selenium.handlers.login.LoginHandler38.java
License:Apache License
public boolean shouldProcessURL(String URL) { System.out.print("============SELENIUM================="); WebDriver driver = new FirefoxDriver(); // And now use this to visit Google driver.get(URL); try {/*from w w w. j a v a 2 s. c om*/ if ((URL == "https://store.kimberamerica.com/customer/account/login") || (URL == "https://palmettostatearmory.com/index.php/customer/account/login/") || (URL == "https://www.osagecountyguns.com/customer/account/login/") || (URL == "https://www.sogknives.com/customer/account/login/") || (URL == "https://www.budsgunshop.com/catalog/login.php")) { System.out.println( "***************************login page***********************************************8"); WebElement email_element = driver.findElement(By.id("email")); email_element.sendKeys("las567vegas@gmail.com"); WebElement pass_element = driver.findElement(By.id("pass")); pass_element.sendKeys("lasvegas"); WebElement submit_element = driver.findElement(By.id("send2")); submit_element.submit(); } else if (URL.contains("page")) { System.out.println( "************************pagination page***********************************************8"); if (URL.contains("http://www.shooting.org/")) driver.findElement(By.xpath("//a[@rel='next']")); else if (URL.contains("https://www.alphacatarmory.com/")) driver.findElement(By.className("next")); else if (URL.contains("http://www.budsgunshop.com/catalog/")) driver.findElement(By.xpath("//a[@class='pageResults' and @title=' Next Page ']")); } } catch (Exception e) { System.out.println("In exception!!!"); } return true; }
From source file:gov.nasa.jpl.memex.nutch.protocol.selenium.handlers.login.LoginHandler8.java
License:Apache License
public void processDriver(WebDriver driver) { URL url;/*from w w w. ja v a 2 s . c o m*/ InputStream is = null; BufferedReader br; String lineContent; PrintWriter writer = null; String currentURL = null; driver.get(url1); try { writer = new PrintWriter("theFile" + i + ".txt", "UTF-8"); i++; } catch (IOException ex) { System.out.println("Something wrong with the PrintWriter"); } try { url = new URL(url1); is = url.openStream(); br = new BufferedReader(new InputStreamReader(is)); while ((lineContent = br.readLine()) != null && writer != null) { writer.println(lineContent); } } catch (MalformedURLException mue) { mue.printStackTrace(); } catch (IOException ioe) { ioe.printStackTrace(); } finally { try { if (is != null) is.close(); } catch (IOException ioe) { } } if (writer != null) { writer.close(); } if (url1.equals("http://www.theoutdoorstrader.com")) { driver.findElement(By.value("loginBar")).click(); driver.findElement(By.id("LoginControl")).sendKeys("will"); driver.findElement(By.id("ctrl_password")).sendKeys("will"); driver.findElement(By.value("Log in")).click(); } currentURL = driver.getCurrentUrl(); try { writer = new PrintWriter("theFile" + i + ".txt", "UTF-8"); i++; } catch (IOException ex) { System.out.println("Something wrong with the PrintWriter"); } try { url = new URL(currentURL); is = url.openStream(); br = new BufferedReader(new InputStreamReader(is)); while ((lineContent = br.readLine()) != null && writer != null) { writer.println(lineContent); } } catch (MalformedURLException mue) { mue.printStackTrace(); } catch (IOException ioe) { ioe.printStackTrace(); } finally { try { if (is != null) is.close(); } catch (IOException ioe) { } } if (writer != null) { writer.close(); } driver.quit(); }
From source file:gov.nasa.jpl.memex.nutch.protocol.selenium.handlers.login.LoginHandlerUK3.java
License:Apache License
public boolean shouldProcessURL(String URL) { WebDriver driver = new FirefoxDriver(); // to resolve selinum issue with Firefox driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS); try {/*from ww w.j a v a 2 s.co m*/ Thread.sleep(10000); } catch (Exception e) { Http.LOG.error("error in try dishant " + e); } Http.LOG.error("trigger" + URL); if (URL.equals("http://www.arguntrader.com")) { Http.LOG.error("in" + URL); // login for arguntrader.com driver.get("http://www.arguntrader.com/ucp.php?mode=login"); WebElement query = driver.findElement(By.id("username")); query.sendKeys("testtest"); query = driver.findElement(By.id("password")); query.sendKeys("password123"); driver.findElement(By.name("login")).click(); } else if (URL.equals("http://www.iguntrade.com")) { Http.LOG.error("in" + URL); // pagination for iguntrade.com driver.get("http://www.iguntrade.com/index.php?page=search"); List<WebElement> allpages = driver.findElements(By.xpath("//div[@class='paginate']//a")); for (int i = 0; i <= (allpages.size()); i++) { allpages.get(i).click(); } } else if (URL.contains("http://www.zidaho.com/category")) { Http.LOG.error("in" + URL); // pagination for zidaho.com List<WebElement> allpages = driver .findElements(By.xpath("//ul[@class='pagination browsing_result_page_links']//a")); for (int i = 0; i <= (allpages.size()); i++) { allpages.get(i).click(); } } return true; }
From source file:gov.nasa.jpl.memex.nutch.protocol.selenium.handlers.login.LoginHandlerUK4.java
License:Apache License
public boolean shouldProcessURL(String URL) { System.console().writer().println("Nutch Crawler CSCI 572"); String url1 = "www.sogknives.com/product/register"; String url2 = "palmettostatearmory.com/index.php/customer/account/login/"; if (URL.contains(url1)) { WebDriver webDriver = new FirefoxDriver(); webDriver.get(URL); webDriver.findElement(By.xpath("//a[contains(.,'Log In')]")).click(); webDriver.findElement(By.id("email")).sendKeys("mail2bigb_21@yahoo.co.in"); webDriver.findElement(By.id("pass")).sendKeys("mail2bigb_21"); webDriver.findElement(By.id("send2")).click(); } else if (URL.contains(url2)) { WebDriver webDriver = new FirefoxDriver(); webDriver.get(URL);/*from www . j a va 2 s. co m*/ webDriver.findElement(By.id("email")).sendKeys("mail2bigb_21@yahoo.co.in"); webDriver.findElement(By.id("pass")).sendKeys("mail2bigb_21"); webDriver.findElement(By.id("send2")).click(); } else { WebDriver webDriver = new FirefoxDriver(); webDriver.get(URL); } return true; }
From source file:gov.nasa.jpl.memex.nutch.protocol.selenium.handlers.misc.MiscHandler1.java
License:Apache License
public void processDriver(WebDriver driver) { FirefoxProfile p = new FirefoxProfile(); p.setPreference("webdriver_firefox_port", 8054); String URL = driver.getCurrentUrl(); Site site = this.matches(URL); if (site == null) return;/* ww w. j av a 2 s .c o m*/ System.out.println("Processing: " + URL); driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS); List<Action> actions = site.getActions(); for (Action action : actions) { String actionType = action.getType(); if (actionType.equals("input")) { WebElement element = findWebElement(action.getBy(), action.getValue(), driver); if (element == null) return; element.sendKeys(action.getKey()); } else if (actionType.equals("click")) { WebElement element = findWebElement(action.getBy(), action.getValue(), driver); if (element == null) return; element.click(); //Wait for a potential new page to load //driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); // driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); } else if (actionType.equals("redirect-append")) { //driver.navigate().to(action.getValue()); //driver.get(action.getValue());//Exactly same as the above driver.get(URL + action.getValue()); //Wait for a potential new page to load /* { Thread.sleep(10000); } catch(Exception e) { e.printStackTrace(); }*/ } driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS); } driver.close(); }
From source file:gov.nasa.jpl.memex.nutch.protocol.selenium.handlers.MultiplePatterns.CS572LoginAndClickHandler.java
License:Apache License
private void loginActionScript(WebDriver driver, WebElement usernameElement, WebElement passwordElement, WebElement submitElement, boolean isEmail) { if (usernameElement != null && passwordElement != null && submitElement != null) { if (isEmail) { usernameElement.sendKeys("cs572testtest@gmail.com"); } else if (driver.getCurrentUrl().contains("carolinabargaintrader.net")) { usernameElement.sendKeys("cs572testtes"); } else {//from www . j a v a2s .c om usernameElement.sendKeys("cs572testtest"); } if (driver.getCurrentUrl().contains("recycler.com")) { passwordElement.sendKeys("s572@testtest"); } else { passwordElement.sendKeys("Cs572@test"); } submitElement.click(); try { Thread.sleep(2300); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } recordHtmlBodyWithDynamicChange(driver); if (refreshFlag) { refreshFlag = false; // refresh page to refresh handler to the un-touched state driver.get(currentURL); } JavascriptExecutor jsx = (JavascriptExecutor) driver; Iterator<String> itr = accumulatedDataArrayList.iterator(); while (itr.hasNext()) { String accumulatedData = itr.next(); try { jsx.executeScript("document.body.innerHTML = document.body.innerHTML + " + "'" + accumulatedData + "'" + ";"); } catch (Exception ee) { System.out.println(ee); } } // System.exit(0); } }
From source file:gov.nasa.jpl.memex.nutch.protocol.selenium.handlers.PageNavigation.PageNavigationUK1.java
License:Apache License
public void processDriverForAcademy(WebDriver driver) { WebElement search = driver.findElement(By.id("item_shooting mainmenu-hunting-firearms")); driver.get(search.findElement(By.tagName("a")).getAttribute("href")); }
From source file:gov.nasa.jpl.memex.nutch.protocol.selenium.handlers.PageNavigation.PageNavigationUK1.java
License:Apache License
public void processDriverForGandermountain(WebDriver driver) { List<WebElement> search = driver.findElements(By.className("top-level-link")); for (WebElement element : search) { String link = element.getAttribute("href"); if (link.contains("guns")) { driver.get(link); return; }/*from w ww.j a v a 2 s. c o m*/ } }