List of usage examples for org.openqa.selenium WebDriver get
void get(String url);
From source file:com.xpanxion.tests.SampleToolsQATest.java
@Test(dataProvider = DataProviderLibrary.DP_GENERIC, dataProviderClass = DataProviderLibrary.class) public void verifyToolsQA_MultipleData(BrowserTypes type) { WebDriver driver = DriverFactory.getDriverInstance(); driver.get("https://mvnrepository.com/"); }
From source file:com.xpanxion.tests.SampleToolsQATest.java
@Test(dataProvider = DataProviderLibrary.VERIFY_TABLE_DATA, dataProviderClass = DataProviderLibrary.class) public void verifyToolsQA(BrowserTypes type, String a, String b) { WebDriver driver = DriverFactory.getDriverInstance(); System.out.println(a);//from ww w .ja v a2s. c o m driver.get("https://mvnrepository.com/"); driver.findElement(By.id("abcd_efcdkfsjfkasdfjads")).click(); }
From source file:com.zhao.crawler.util.PageUtils.java
License:Open Source License
/** * ?PhantomJsDriver(??js??html)//from w w w .j a v a 2 s. co m * * @param page * @return */ public static WebDriver getWebDriver(Page page) { // WebDriver driver = new HtmlUnitDriver(true); // System.setProperty("webdriver.chrome.driver", "D:\\Installs\\Develop\\crawling\\chromedriver.exe"); // WebDriver driver = new ChromeDriver(); System.setProperty("phantomjs.binary.path", "C:/nevi/env/phantomjs-2.1.1-windows/bin/phantomjs.exe"); WebDriver driver = new PhantomJSDriver(); driver.get(page.getUrl()); // JavascriptExecutor js = (JavascriptExecutor) driver; // js.executeScript("function(){}"); return driver; }
From source file:conexiones.HTMLData.java
private static int dataContaduria(Expediente exp, Estados estado) { WebDriver driver = new HtmlUnitDriver(); try {//w w w. j a va2 s . co m driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); driver.get(URL_CONTADURIA); driver.findElement(By.id("ctl00_ContentPlaceHolder1_tbCaratula")).clear(); driver.findElement(By.id("ctl00_ContentPlaceHolder1_tbCaratula")).sendKeys(exp.getCaratula()); driver.findElement(By.id("ctl00_ContentPlaceHolder1_tbNumero")).clear(); driver.findElement(By.id("ctl00_ContentPlaceHolder1_tbNumero")).sendKeys(exp.getNumero()); driver.findElement(By.id("ctl00_ContentPlaceHolder1_tbAnio")).clear(); driver.findElement(By.id("ctl00_ContentPlaceHolder1_tbAnio")).sendKeys(exp.getAnio()); driver.findElement(By.id("ctl00_ContentPlaceHolder1_tbAlcance")).clear(); driver.findElement(By.id("ctl00_ContentPlaceHolder1_tbAlcance")).sendKeys(exp.getAlcance()); driver.findElement(By.id("ctl00_ContentPlaceHolder1_btnConsultar")).submit(); driver.manage().timeouts().implicitlyWait(100, TimeUnit.NANOSECONDS); try { estado.setEstado(driver.findElement(By.id("lblJur")).getText()); estado.setFechaCon(driver.findElement(By.id("lblEgreFecha")).getText()); estado.setFechaE(estado.getFechaCon()); estado.setPagina(""); return EXP_ENCONTRADO; } catch (NoSuchElementException e) { try { //el expediente esta en contaduria. estado.setEstado( driver.findElement(By.id("ctl00_ContentPlaceHolder1_lblOficinaActual")).getText()); estado.setFechaR( driver.findElement(By.id("ctl00_ContentPlaceHolder1_lblFechaIngreso")).getText()); estado.setPagina("Contaduria"); return EXP_ENCONTRADO; } catch (NoSuchElementException ex) { return EXP_NO_ENCONTRADO; //No se encontro el expediente } } } catch (Exception ex) { return ERROR_PAGINA; //No es posible acceder a la pagina } finally { driver.quit(); } }
From source file:Controller.ControllerTest.java
public void runTest() { WebDriver driver = new ChromeDriver(); driver.get("http://google.com"); }
From source file:cuenen.raymond.svgplot.AbstractTestClass.java
License:CDDL license
/** * Load the given resource into the browser. This also sets the document's * title to the implementing class name. * * @param driver The WebDriver executing the test. * @param resource The resource to be loaded. * @param timeout The timeout in seconds of the returned {@code Wait} * object./*from w ww . j a v a 2 s . c o m*/ * @return The {@code Wait} object obtained from the WebDriver. */ protected Wait load(WebDriver driver, String resource, int timeout) { driver.get(BASE_URL + CONTEXT + resource); if (driver instanceof JavascriptExecutor) { ((JavascriptExecutor) driver).executeScript(TITLE_SCRIPT, getClass().getSimpleName()); } return new WebDriverWait(driver, timeout); }
From source file:Data.Database.java
public void addTeams() throws InterruptedException, FileNotFoundException { Scanner fileScanner = new Scanner(new File("login.txt")); String username = fileScanner.nextLine(); String password = fileScanner.nextLine(); WebDriver firefoxDriver = new FirefoxDriver(); //Open the url which we want in firefox firefoxDriver.get("http://www.fantrax.com/fantasy/teamRosterChart.go?leagueId=ntokropui8nbbjt1"); WebElement link;//from w w w. ja v a 2s . co m link = firefoxDriver.findElement(By.id("loginZone")); link.click(); WebElement input; input = firefoxDriver.findElement(By.id("j_username")); input.sendKeys(username); input = firefoxDriver.findElement(By.id("realPassword")); input.sendKeys(password); input.sendKeys(Keys.RETURN); Thread.sleep(2000); firefoxDriver.get("http://www.fantrax.com/fantasy/teamRosterChart.go?leagueId=ntokropui8nbbjt1"); String data = firefoxDriver.getPageSource(); data = data.substring(data.indexOf("<table class=\"fantTable rosterChart\">")); data = data.substring(0, data.indexOf("</tbody>")); String[] temp = data.split("<td class=\"team leftCol\">"); //System.out.println(temp[1]); for (int i = 1; i < temp.length; i++) { Team t = new Team(); t.fillTeam(years, lookup, temp[i]); fh_teams.add(t); t.getTotals(); t.printAverages(); } firefoxDriver.quit(); }
From source file:db.Db.java
static boolean regAccount(String a[][], String referralUrl, int f, WebDriver driver) throws InterruptedException { String name = a[f][0], shurname = a[f][1], password = a[f][2], mail = a[f][3]; boolean ispresent = false, registered = false; String gsUrl = "https://www.dropbox.com/gs"; driver.get(referralUrl); for (int second = 0;; second++) { if (second >= 30) { System.out.println("Connection timeout"); break; }//from ww w . java2s.com //ispresent try { driver.findElement(By.xpath("//div[2]/div/div/form/div[2]/div[2]/input")); ispresent = true; } catch (NoSuchElementException e) { ispresent = false; } try { if (ispresent) break; } catch (Exception e) { } Thread.sleep(1000); } Thread.sleep(100); if (ispresent) { driver.findElement(By.xpath("//div[2]/div/div/form/div[2]/div[2]/input")).clear(); driver.findElement(By.xpath("//div[2]/div/div/form/div[2]/div[2]/input")).sendKeys(name); driver.findElement(By.xpath("//div[2]/div/div/form/div[3]/div[2]/input")).clear(); driver.findElement(By.xpath("//div[2]/div/div/form/div[3]/div[2]/input")).sendKeys(shurname); driver.findElement(By.xpath("//div[5]/div[2]/input")).clear(); driver.findElement(By.xpath("//div[5]/div[2]/input")).sendKeys(password); driver.findElement(By.xpath("//div[2]/div/div/form/div[4]/div[2]/input")).clear(); driver.findElement(By.xpath("//div[2]/div/div/form/div[4]/div[2]/input")).sendKeys(mail); driver.findElement(By.xpath("//div[6]/input")).click(); //Check tos agree Thread.sleep(100); driver.findElement(By.xpath("//div[2]/div/div/form/button")).click(); //Submit register form for (int second = 0;; second++) { if (second >= 15) { System.out.println("Submitting form timeout"); break; } if (gsUrl.equals(driver.getCurrentUrl())) registered = true; try { if (registered) break; } catch (Exception e) { } Thread.sleep(1000); } } int n = f + 1; if (registered) System.out.print(""); else System.out.print("x"); driver.manage().deleteAllCookies(); return registered; //returns true or false }
From source file:de.codecentric.janus.plugin.library.SeleniumAdapter.java
License:Apache License
private void reloadConfiguration() throws Exception { assert driver != null; int timeoutInSeconds = Config.getTimeoutInSeconds(); if (Config.isRestartReloadStrategy()) { driver.get(Config.getJenkinsBaseUrl() + "restart"); driver.findElement(By.cssSelector("form[action=\"restart\"] " + "button")).click(); timeoutInSeconds *= 6;/*from ww w. j a v a2s.c om*/ } else { driver.get(Config.getJenkinsBaseUrl() + "reload"); } new WebDriverWait(driver, timeoutInSeconds).until(new ExpectedCondition<Boolean>() { @Override public Boolean apply(@Nullable WebDriver driver) { return driver.getTitle().startsWith("Dashboard"); } }); }
From source file:de.dentrassi.pm.testing.WebContext.java
License:Open Source License
public default WebDriver getResolved(final String url) { final WebDriver driver = getDriver(); driver.get(resolve(url)); return driver; }