List of usage examples for org.openqa.selenium WebDriver get
void get(String url);
From source file:org.terasoluna.tourreservation.tourreserve.common.FunctionTestSupport.java
License:Apache License
/** * Starts a WebDriver<br>//from w ww . ja v a 2 s . c o m * </p> * @return WebDriver web driver */ protected WebDriver createWebDriver() { WebDriver driver = null; for (String activeProfile : getApplicationContext().getEnvironment().getActiveProfiles()) { if ("chrome".equals(activeProfile)) { driver = new ChromeDriver(); break; } else if ("firefox".equals(activeProfile)) { break; } else if ("ie".equals(activeProfile)) { driver = new InternetExplorerDriver(); break; } } if (driver == null) { driver = new FirefoxDriver(); } driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); driver.get(applicationContextUrl + "?locale=" + locale.getLanguage()); return driver; }
From source file:org.webbench.SeleniumServerRun.java
License:Apache License
public static void main(String[] args) throws Exception { // We could use any driver for our tests... DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer(); // ... but only if it supports javascript capabilities.setJavascriptEnabled(true); // Get a handle to the driver. This will throw an exception // if a matching driver cannot be located WebDriver driver1 = new RemoteWebDriver(new URL("http://127.0.0.1:4444/wd/hub"), capabilities); // Query the driver to find out more information // Capabilities actualCapabilities = ((RemoteWebDriver) driver1).getCapabilities(); // And now use it driver1.get("http://www.google.com"); // WebDriver driver2 = new RemoteWebDriver(new URL("http://127.0.0.1:4444/wd/hub"), capabilities); // driver2.get("http://www.google.com"); // Thread.sleep(60000); driver1.close();/*from ww w . j ava2 s .co m*/ // driver2.close(); }
From source file:org.webbench.SimpleScenarioRun.java
License:Apache License
public static void main(String args[]) throws Exception { WebDriver driver1 = null; WebDriver driver2 = null;/*from w ww .j a v a 2s.c om*/ try { driver1 = new InternetExplorerDriver(); driver1.get("http://www.google.com"); Thread.sleep(5000); System.out.println("launch 2sd ie"); driver2 = new InternetExplorerDriver(); driver2.get("http://www.google.com"); Thread.sleep(5000); } finally { if (driver1 != null) { System.out.println("close 1th ie"); driver1.quit(); } if (driver2 != null) { System.out.println("close 2sd ie"); driver2.quit(); } } System.out.println("end"); }
From source file:org.wso2.appmanager.ui.integration.test.pages.LoginPage.java
License:Open Source License
public static LoginPage getPage(WebDriver driver, AutomationContext appMServer, LoginTo loginTo) throws IOException, XPathExpressionException { if (loginTo == LoginTo.PUBLISHER) { driver.get(appMServer.getContextUrls().getWebAppURLHttps() + PUBLISHER_LOGIN_URI); } else {/*from w w w. j a v a 2 s . c o m*/ driver.get(appMServer.getContextUrls().getWebAppURLHttps() + STORE_LOGIN_URI); } if (page == null || page.driver != driver) { page = new LoginPage(driver, appMServer); } return page; }
From source file:org.wso2.appserver.ui.integration.test.webapp.spring.SpringWebApplicationDeploymentTestCase.java
License:Open Source License
@Test(groups = "wso2.as", description = "Access the spring application", dependsOnMethods = "webApplicationDeploymentTest", enabled = false) public void invokeSpringApplicationTest() throws Exception { WebDriver driverForApp = null; try {//from w ww .j a va2s. c o m driverForApp = BrowserManager.getWebDriver(); //Go to application driverForApp.get(webAppURL + "/booking-faces/spring/intro"); driverForApp.findElement(By.linkText("Start your Spring Travel experience")).click(); //searching hotels to reserve driverForApp.findElement(By.xpath("//*[@id=\"j_idt13:searchString\"]")).sendKeys("Con"); driverForApp.findElement(By.xpath("//*[@id=\"j_idt13:findHotels\"]")).click(); //view hotel information driverForApp.findElement(By.xpath("//*[@id=\"j_idt12:hotels:0:viewHotelLink\"]")).click(); //go to book hotel driverForApp.findElement(By.xpath("//*[@id=\"hotel:book\"]")).click(); //providing user name and password driverForApp.findElement(By.xpath("/html/body/div/div[3]/div[2]/div[2]/form/fieldset/p[1]/input")) .sendKeys("keith"); driverForApp.findElement(By.xpath("/html/body/div/div[3]/div[2]/div[2]/form/fieldset/p[2]/input")) .sendKeys("melbourne"); //authenticating driverForApp.findElement(By.xpath("/html/body/div/div[3]/div[2]/div[2]/form/fieldset/p[4]/input")) .click(); //booking hotel driverForApp.findElement(By.xpath("//*[@id=\"hotel:book\"]")).click(); //providing payments information driverForApp.findElement(By.xpath("//*[@id=\"bookingForm:creditCard\"]")).sendKeys("1234567890123456"); driverForApp.findElement(By.xpath("//*[@id=\"bookingForm:creditCardName\"]")).sendKeys("xyz"); //proceed transaction driverForApp.findElement(By.xpath("//*[@id=\"bookingForm:proceed\"]")).click(); //confirm booking driverForApp.findElement(By.xpath("//*[@id=\"j_idt13:confirm\"]")).click(); //verify whether the hotel booked is in the booked hotel tabled Assert.assertEquals(driverForApp.findElement(By.xpath("//*[@id=\"bookings_header\"]")).getText(), "Your Hotel Bookings", "Booked Hotel table Not Found"); //verify the hotel name is exist in the booked hotel table Assert.assertEquals( driverForApp.findElement(By.xpath("//*[@id=\"j_idt23:j_idt24_data\"]/tr/td[1]")).getText(), "Conrad Miami\n" + "1395 Brickell Ave\n" + "Miami, FL", "Hotel Name mismatch"); } finally { if (driverForApp != null) { driverForApp.quit(); } } }
From source file:org.wso2.carbon.appmanager.integration.ui.Util.APPMPublisherUIClient.java
License:Open Source License
/** * Log in to the APP_M store// w w w . j a v a 2s . c o m * * @param driver selenium WebDriver. * @param backEndUrl store host * @param username username * @param password password */ public void login(WebDriver driver, String backEndUrl, String username, String password) { driver.get(backEndUrl + uiElementMapper.getElement("publisher_url")); WebDriverWait wait = new WebDriverWait(driver, 30); wait.until(ExpectedConditions .visibilityOfElementLocated(new ByAll(By.className("btn-primary"), By.tagName("input")))); wait.until(ExpectedConditions .visibilityOfElementLocated(By.id(uiElementMapper.getElement("publisher_username_id_locator")))); WebElement usernameEle = driver .findElement(By.id(uiElementMapper.getElement("publisher_username_id_locator"))); usernameEle.sendKeys(username); // find element password wait.until(ExpectedConditions .visibilityOfElementLocated(By.id(uiElementMapper.getElement("publisher_password_id_locator")))); WebElement passwordEle = driver .findElement(By.id(uiElementMapper.getElement("publisher_password_id_locator"))); // fill element passwordEle.sendKeys(password); // find submit button and click on it. driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS); driver.findElement(new ByAll(By.className("btn-primary"), By.tagName("input"))).click(); }
From source file:org.wso2.carbon.appmanager.integration.ui.Util.APPMPublisherUIClient.java
License:Open Source License
/** * Logout from the APP_M store//w w w . j a va2 s .c o m * * @param driver selenium WebDriver. * @param backEndUrl store host */ public String logout(WebDriver driver, String backEndUrl) { driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS); WebDriverWait wait = new WebDriverWait(driver, 30); driver.get(backEndUrl + uiElementMapper.getElement("pubisher_url")); wait.until(ExpectedConditions .visibilityOfElementLocated(By.xpath(uiElementMapper.getElement("store_dropdown_xpath_locator")))); driver.findElement(By.xpath(uiElementMapper.getElement("store_dropdown_xpath_locator"))).click(); wait.until(ExpectedConditions .visibilityOfElementLocated(By.xpath(uiElementMapper.getElement("store_sign_out_xpath_locator")))); driver.findElement(By.xpath(uiElementMapper.getElement("store_sign_out_xpath_locator"))).click(); return driver.getCurrentUrl(); }
From source file:org.wso2.carbon.appmanager.integration.ui.Util.APPMStoreUIClient.java
License:Open Source License
/** * Log in to the APP_M store//from ww w.j a v a2 s . co m * * @param driver selenium WebDriver. * @param backEndUrl store host * @param username username * @param password password */ public void login(WebDriver driver, String backEndUrl, String username, String password) { driver.get(backEndUrl + uiElementMapper.getElement("store_url")); WebDriverWait wait = new WebDriverWait(driver, 30); wait.until(ExpectedConditions.visibilityOfElementLocated( By.linkText(uiElementMapper.getElement("store_sign_in_link_text_locator")))); driver.findElement(By.linkText(uiElementMapper.getElement("store_sign_in_link_text_locator"))).click(); wait.until(ExpectedConditions .visibilityOfElementLocated(By.id(uiElementMapper.getElement("store_username_id_locator")))); WebElement usernameEle = driver.findElement(By.id(uiElementMapper.getElement("store_username_id_locator"))); usernameEle.sendKeys(username); // find element password wait.until(ExpectedConditions .visibilityOfElementLocated(By.id(uiElementMapper.getElement("store_password_id_locator")))); WebElement passwordEle = driver.findElement(By.id(uiElementMapper.getElement("store_password_id_locator"))); // fill element passwordEle.sendKeys(password); // find submit button and click on it. driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS); driver.findElement(By.className(uiElementMapper.getElement("store_button_class_name_locator"))).click(); }
From source file:org.wso2.carbon.appmanager.integration.ui.Util.APPMStoreUIClient.java
License:Open Source License
public WebDriver loginDriver(WebDriver driver, String backEndUrl, String username, String password) { driver.get(backEndUrl + uiElementMapper.getElement("store_url")); WebDriverWait wait = new WebDriverWait(driver, 30); wait.until(ExpectedConditions.visibilityOfElementLocated( By.linkText(uiElementMapper.getElement("store_sign_in_link_text_locator")))); driver.findElement(By.linkText(uiElementMapper.getElement("store_sign_in_link_text_locator"))).click(); wait.until(ExpectedConditions/*from w ww. j av a2 s. co m*/ .visibilityOfElementLocated(By.id(uiElementMapper.getElement("store_username_id_locator")))); WebElement usernameEle = driver.findElement(By.id(uiElementMapper.getElement("store_username_id_locator"))); usernameEle.sendKeys(username); // find element password wait.until(ExpectedConditions .visibilityOfElementLocated(By.id(uiElementMapper.getElement("store_password_id_locator")))); WebElement passwordEle = driver.findElement(By.id(uiElementMapper.getElement("store_password_id_locator"))); // fill element passwordEle.sendKeys(password); // find submit button and click on it. driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS); driver.findElement(By.className(uiElementMapper.getElement("store_button_class_name_locator"))).click(); for (String winHandle : driver.getWindowHandles()) { driver.switchTo().window(winHandle); } return driver; }