List of usage examples for org.openqa.selenium WebDriver get
void get(String url);
From source file:com.thoughtworks.inproctester.tests.InProcessHtmlUnitDriverTest.java
License:Apache License
@Test public void shouldSupportUtfEncodedData() { WebDriver htmlUnitDriver = new InProcessHtmlUnitDriver(httpAppTester); htmlUnitDriver.get("http://localhost/contacts/add"); WebElement contactNameElement = htmlUnitDriver.findElement(By.name("contactName")); contactNameElement.clear();// w w w .j ava2 s. c o m contactNameElement.sendKeys("? "); htmlUnitDriver.findElement(By.tagName("form")).submit(); assertThat(htmlUnitDriver.findElement(By.name("contactName")).getAttribute("value"), is("? ")); }
From source file:com.thoughtworks.inproctester.tests.InProcessHtmlUnitDriverTest.java
License:Apache License
@Test public void shouldSupportCookies() { WebDriver htmlUnitDriver = new InProcessHtmlUnitDriver(httpAppTester); htmlUnitDriver.manage().deleteAllCookies(); htmlUnitDriver.get("http://localhost/contacts/add"); htmlUnitDriver.findElement(By.name("contactName")).sendKeys("My Contact"); htmlUnitDriver.findElement(By.tagName("form")).submit(); assertThat(htmlUnitDriver.findElement(By.className("message")).getText(), is("Success")); htmlUnitDriver.get("http://localhost/contacts/1"); Cookie flashMessageCookie = htmlUnitDriver.manage().getCookieNamed("FLASH_MESSAGE"); assertThat(flashMessageCookie, is(nullValue())); assertThat(htmlUnitDriver.findElements(By.className("message")), is(Matchers.<WebElement>empty())); }
From source file:com.thoughtworks.inproctester.tests.InProcessHtmlUnitDriverTestWithWebXml.java
License:Apache License
@Test public void shouldSupportGetAndPostRequests() { WebDriver htmlUnitDriver = new InProcessHtmlUnitDriver(httpAppTester); htmlUnitDriver.get("http://localhost/contacts/add"); assertThat(htmlUnitDriver.getTitle(), is("Test Application")); assertThat(htmlUnitDriver.findElement(By.tagName("h3")).getText(), is("Contact Details")); WebElement contactNameElement = htmlUnitDriver.findElement(By.name("contactName")); assertThat(contactNameElement.getAttribute("value"), isEmptyString()); contactNameElement.sendKeys("My Contact"); htmlUnitDriver.findElement(By.tagName("form")).submit(); assertThat(htmlUnitDriver.getCurrentUrl(), is("http://localhost/contacts/1")); assertThat(htmlUnitDriver.findElement(By.name("contactName")).getAttribute("value"), is("My Contact")); }
From source file:com.thoughtworks.selenium.corerunner.CoreTest.java
License:Apache License
public void run(Results results, WebDriver driver, Selenium selenium) { if (!driver.getCurrentUrl().equals(url)) { driver.get(url); }/*from w w w. j av a2 s .c o m*/ // Are we running a suite or an individual test? List<WebElement> allTables = driver.findElements(By.id("suiteTable")); if (allTables.isEmpty()) { new CoreTestCase(url).run(results, driver, selenium); } else { new CoreTestSuite(url).run(results, driver, selenium); } }
From source file:com.thoughtworks.selenium.corerunner.CoreTestCase.java
License:Apache License
public void run(Results results, WebDriver driver, Selenium selenium) { String currentUrl = driver.getCurrentUrl(); if (!url.equals(currentUrl)) { driver.get(url); }/*from ww w. j a v a 2 s .c o m*/ List<CoreTestStep> steps = findCommands(driver); for (CoreTestStep step : steps) { step.run(results, driver, selenium); } }
From source file:com.thoughtworks.selenium.corerunner.CoreTestSuite.java
License:Apache License
public void run(Results results, WebDriver driver, Selenium selenium) { if (!url.equals(driver.getCurrentUrl())) { driver.get(url); }/*from w w w.j a va2 s. c o m*/ List<WebElement> allTables = driver.findElements(By.id("suiteTable")); if (allTables.isEmpty()) { throw new SeleniumException("Unable to locate suite table: " + url); } List<String> allTestUrls = (List<String>) ((JavascriptExecutor) driver).executeScript( "var toReturn = [];\n" + "for (var i = 0; i < arguments[0].rows.length; i++) {\n" + " if (arguments[0].rows[i].cells.length == 0) {\n" + " continue;\n" + " }\n" + " var cell = arguments[0].rows[i].cells[0];\n" + " if (!cell) { continue; }\n" + " var allLinks = cell.getElementsByTagName('a');\n" + " if (allLinks.length > 0) {\n" + " toReturn.push(allLinks[0].href);\n" + " }\n" + "}\n" + "return toReturn;\n", allTables.get(0)); for (String testUrl : allTestUrls) { new CoreTest(testUrl).run(results, driver, selenium); } }
From source file:com.thoughtworks.selenium.webdriven.commands.Open.java
License:Apache License
@Override protected Void handleSeleneseCommand(final WebDriver driver, String url, String ignored) { try {/*from www . ja v a 2 s . c om*/ final String urlToOpen = url.indexOf("://") == -1 ? new URL(baseUrl, url).toString() : url; driver.get(urlToOpen); } catch (MalformedURLException e) { throw new SeleniumException(e.getMessage(), e); } return null; }
From source file:com.tribuneqa.utilities.FrameworkUtilities.java
public void loadAndResize(WebDriver driver, String uri, int xAxis, int yAxis) { driver.manage().window().setSize(new Dimension(xAxis, yAxis)); driver.get(FrameworkProperties.HOMEPAGE_URL + uri); }
From source file:com.twiceagain.mywebdriver.driver.web.DriversTest.java
License:Open Source License
protected String openPage(WebDriver wd) { wd.get("http://www.google.com"); return wd.getTitle(); }
From source file:com.twiceagain.mywebdriver.startup.DemoBasicWebPageVisualizeElements.java
License:Open Source License
/** * @param args the command line arguments * @throws java.lang.InterruptedException *///from w ww. j a v a2s. co m public static void main(String[] args) throws InterruptedException { WebDriver wd = Drivers.getDriver(); wd.get("https://news.google.com"); //Thread.sleep(2000); List<WebElement> lwe = wd.findElements(By.xpath(".//div[@class='esc-body']")); Drivers.highlightElements(wd, lwe, "article"); Thread.sleep(5000);// wait 5 secs wd.close(); }