List of usage examples for org.openqa.selenium WebDriver get
void get(String url);
From source file:net.mindengine.galen.tests.api.GalenTest.java
License:Apache License
@Test public void checkLayout_shouldTestLayout_andReturnLayoutReport() throws IOException { WebDriver driver = new MockedDriver(); driver.get("/mocks/pages/galen4j-sample-page.json"); LayoutReport layoutReport = Galen.checkLayout(driver, "/specs/galen4j/sample-spec-with-error.spec", asList("mobile"), null, new Properties(), null); assertThat(layoutReport.getValidationErrorResults(), contains(//from w w w.j a va2s .c o m new ValidationResult( asList(new ValidationObject(new Rect(10, 10, 100, 50), "save-button"), new ValidationObject(new Rect(120, 10, 200, 50), "name-textfield")), new ValidationError().withMessage("\"save-button\" is 10px left instead of 50px")), new ValidationResult(asList(new ValidationObject(new Rect(10, 10, 100, 50), "save-button")), new ValidationError() .withMessage("\"save-button\" text is \"Save\" but should be \"Store\"")))); }
From source file:net.mindengine.galen.tests.api.GalenTest.java
License:Apache License
@Test public void dumpPage_shouldOnlyStoreScreenshots_thatAreLessThan_theMaxAllowed() throws IOException { String pageDumpPath = Files.createTempDir().getAbsolutePath() + "/pagedump"; WebDriver driver = new MockedDriver(); driver.get("/mocks/pages/galen4j-pagedump.json"); Galen.dumpPage(driver, "test page", "/specs/galen4j/pagedump.spec", pageDumpPath, 80, 80); assertFileExists(pageDumpPath + "/objects/button-save.png"); assertFileDoesNotExist(pageDumpPath + "/objects/name-textfield.png"); assertFileExists(pageDumpPath + "/objects/menu-item-1.png"); assertFileExists(pageDumpPath + "/objects/menu-item-2.png"); assertFileExists(pageDumpPath + "/objects/menu-item-3.png"); assertFileDoesNotExist(pageDumpPath + "/objects/big-container.png"); }
From source file:net.mindengine.galen.tests.specs.reader.PageSpecsReaderTest.java
License:Apache License
@Test public void shouldAllow_toCountObject_byIvoking_JavascriptFunction() throws IOException { WebDriver driver = new MockedDriver(); driver.get("/mocks/pages/count-via-js-page.json"); PageSpecReader pageSpecReader = new PageSpecReader(EMPTY_PROPERTIES, new SeleniumBrowser(driver).getPage()); PageSpec pageSpec = pageSpecReader.read(getClass().getResource("/specs/count-via-js.spec").getFile()); List<ObjectSpecs> objectSpecs = pageSpec.getSections().get(0).getObjects(); assertThat(objectSpecs.size(), is(3)); assertThat(objectSpecs.get(0).getObjectName(), is("menu-item-1")); assertThat(objectSpecs.get(1).getObjectName(), is("menu-item-2")); assertThat(objectSpecs.get(2).getObjectName(), is("menu-item-3")); assertThat(objectSpecs.get(0).getSpecs().get(0).getOriginalText(), is("near: menu-item-2 0px left")); assertThat(objectSpecs.get(1).getSpecs().get(0).getOriginalText(), is("near: menu-item-3 0px left")); assertThat(objectSpecs.get(2).getSpecs().get(0).getOriginalText(), is("near: menu-item-4 0px left")); }
From source file:net.mindengine.galen.tests.specs.reader.PageSpecsReaderTest.java
License:Apache License
/** * Comes from a bug report #134//from w ww. j ava 2 s. c o m * The problem was that the count couldn't find all objects in case the page spec had an import of other spec * @throws IOException */ @Test public void should_countObjects_evenWhenUsing_emptyImports() throws IOException { WebDriver driver = new MockedDriver(); driver.get("/mocks/pages/count-via-js-page.json"); PageSpec pageSpec = new PageSpecReader(EMPTY_PROPERTIES, new SeleniumBrowser(driver).getPage()) .read(getClass().getResource("/specs/count-bug-134.spec").getFile()); List<ObjectSpecs> objectSpecs = pageSpec.getSections().get(0).getObjects(); assertThat(objectSpecs.get(0).getSpecs().get(0).getOriginalText(), is("text is: A count is 4")); }
From source file:net.mindengine.galen.tests.specs.reader.PageSpecsReaderTest.java
License:Apache License
/** Comes from a bug in version 1.4.0 *//*ww w .j ava2 s .co m*/ @Test public void should_countObject_insideSecondarySpec() throws IOException { WebDriver driver = new MockedDriver(); driver.get("/mocks/pages/count-via-js-page.json"); PageSpec pageSpec = new PageSpecReader(EMPTY_PROPERTIES, new SeleniumBrowser(driver).getPage()) .read(getClass().getResource("/specs/count/main.spec").getFile()); List<ObjectSpecs> objectSpecs = pageSpec.getSections().get(0).getObjects(); assertThat(objectSpecs.get(0).getSpecs().get(0).getOriginalText(), is("text is: A count is 4")); }
From source file:net.mindengine.galen.tests.specs.reader.PageSpecsReaderTest.java
License:Apache License
@Test public void shouldAllowToUse_pageObjectProperties_inJsExpressions_via_findFunction() throws IOException { WebDriver driver = new MockedDriver(); driver.get("/mocks/pages/object-values-in-js.json"); PageSpecReader specReader = new PageSpecReader(new Properties(), new SeleniumBrowser(driver).getPage()); PageSpec pageSpec = specReader//from ww w. j a v a2 s . c om .read(getClass().getResource("/specs/spec-with-object-values-in-js.spec").getFile()); assertThat(pageSpec.getSections().get(0).getObjects().get(0).getSpecs().get(0).getOriginalText(), is("near: menu-item-4 20px left")); assertThat(pageSpec.getSections().get(0).getObjects().get(0).getSpecs().get(1).getOriginalText(), is("above: menu-item-4 30px")); }
From source file:net.mindengine.galen.tests.specs.reader.PageSpecsReaderTest.java
License:Apache License
/** Discovered a bug in version 1.4.3 * There was a bug that js function 'find' couldn't find all objects when the spec was invoked via import * @throws IOException//from w ww . j a v a2 s. c o m */ @Test public void shouldAllowToUse_pageObjectProperties_inJsExpressions_via_findFunction_withImportedSpecs() throws IOException { WebDriver driver = new MockedDriver(); driver.get("/mocks/pages/object-values-in-js.json"); PageSpecReader specReader = new PageSpecReader(new Properties(), new SeleniumBrowser(driver).getPage()); PageSpec pageSpec = specReader .read(getClass().getResource("/specs/spec-with-object-values-in-js-via-import.spec").getFile()); assertThat(pageSpec.getSections().get(0).getObjects().get(0).getSpecs().get(0).getOriginalText(), is("near: menu-item-4 20px left")); assertThat(pageSpec.getSections().get(0).getObjects().get(0).getSpecs().get(1).getOriginalText(), is("above: menu-item-4 30px")); }
From source file:net.osgiliath.messaging.repository.impl.itests.ITHelloWebUITest.java
License:Apache License
@Test public void testSayHello() throws Exception { final WebDriver driver; driver = new FirefoxDriver(); // Sleep until the elements we want is visible or 5 seconds is over long end = System.currentTimeMillis() + 10000; (new WebDriverWait(driver, 300)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { driver.get("http://localhost:8181/net.osgiliath.hello.ui"); boolean ret = d.getTitle().toLowerCase().startsWith("hello"); if (!ret) { driver.navigate().refresh(); }/*from ww w .j a va 2 s.c om*/ return ret; } }); WebElement element; element = driver.findElement(By.id("helloInput")); element.click(); element.sendKeys(CORRECT_NAME); element = driver.findElement(By.id("helloButton")); element.click(); (new WebDriverWait(driver, 20)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { Collection<WebElement> cells = d.findElements(By.xpath("//table//tr//td")); return cells.size() == 1; } }); end = System.currentTimeMillis() + 10000; driver.close(); }
From source file:newMember.newTrial.java
License:Open Source License
public static void main(String[] args) throws IOException { //setProperty(a,b): Ensure b is set to path of gecko driver //ClassLoader loader = ClassLoader.getSystemClassLoader(); //URL path = loader.getResource("geckodriver.exe"); ClassLoader cl = Thread.currentThread().getContextClassLoader(); URL url = cl.getResource("geckodriver/geckodriver/geckodriver.exe"); System.setProperty("webdriver.chrome.driver", url.getPath()); //System.setProperty("webdriver.gecko.driver", "C:/Users/Sherlock Mind Palace/workspace/TrialRun/geckodriver/geckodriver.exe"); WebDriver driver = new FirefoxDriver(); DesiredCapabilities capabilities = DesiredCapabilities.firefox(); capabilities.setCapability("marionette", true); //Go to testing site driver.get("https://apptimize.com"); //Click on Sign Up button driver.findElement(By.xpath("//a[@href='/30-day-trial']")).click(); //Search for id fname for 10 seconds before giving up WebElement fname = (new WebDriverWait(driver, 10)) .until(ExpectedConditions.presenceOfElementLocated(By.id("fname"))); fname.sendKeys(member.fName);/*ww w . j av a2s. c o m*/ WebElement lname = driver.findElement(By.id("lname")); lname.sendKeys(member.lName); //Fill in email field WebElement email = driver.findElement(By.id("email")); email.sendKeys(member.eMail); //Fill in Company name WebElement cname = driver.findElement(By.id("company")); cname.sendKeys("Apptimize Candidate"); //Fill in Phone and Job field WebElement phone = driver.findElement(By.id("phone")); phone.sendKeys(member.pNumber); WebElement jtitle = driver.findElement(By.id("jobtitle")); jtitle.sendKeys(member.jTitle); //Create password WebElement password = driver.findElement(By.id("password")); password.sendKeys(member.pWord); //Select No to software radio question WebElement rNo = driver.findElement(By.xpath("//input[@name='purchased' and @value='No']")); rNo.click(); //Select End User License Agreement Checkbox WebElement read = driver.findElement(By.id("eula")); read.click(); //WebElement submit = driver.findElement(By.id("submit")); //submit.click(); System.out.println("You successfully signed up for trial account."); driver.quit(); }
From source file:objective.taskboard.it.MainPage.java
License:Open Source License
public static MainPage to(WebDriver webDriver) { webDriver.get(AbstractUIIntegrationTest.getSiteBase() + "/"); return initElements(webDriver, MainPage.class); }