List of usage examples for org.openqa.selenium WebDriver get
void get(String url);
From source file:JavaClasses.DBConnectionIT.java
@Test public void testSimple() throws Exception { // Create a new instance of the Firefox driver // Notice that the remainder of the code relies on the interface, // not the implementation. //WebDriver driver = new FirefoxDriver(); WebDriver driver = new HtmlUnitDriver(); driver.get("http://54.255.142.60:8080/PhoenixConsulting-1.0-SNAPSHOT/index.jsp"); // Check the title of the page // Wait for the page to load, timeout after 10 seconds //(new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() { // @Override //public Boolean apply(WebDriver d) { // return d.getTitle().contains("NetBeans"); //}/*from w ww . ja v a 2 s . co m*/ String actualTitle = driver.getTitle(); assertTrue(actualTitle.equalsIgnoreCase("Home Page - Phoenix")); WebElement element = driver.findElement(By.name("submit")); element.click(); actualTitle = driver.getTitle(); assertTrue(actualTitle.equalsIgnoreCase("Phoenix Consulting - Details")); element = driver.findElement(By.name("back")); element.click(); actualTitle = driver.getTitle(); assertTrue(actualTitle.equalsIgnoreCase("Home Page - Phoenix")); //Close the browser driver.quit(); }
From source file:javafxapplication3.FXMLDocumentController.java
@FXML private void processButtonAction(ActionEvent event) throws AWTException, InterruptedException, IOException { WebDriver driver = new FirefoxDriver(); driver.get("http://spreadsheetpage.com/index.php/file/C35/P10/"); // sample url driver.findElement(By.xpath(".//a[@href=contains(text(),'yearly-calendar.xls')]")).click(); Robot robot = new Robot(); // Robot class throws AWT Exception Thread.sleep(2000); // Thread.sleep throws InterruptedException robot.keyPress(KeyEvent.VK_DOWN); // press arrow down key of keyboard to navigate and select Save radio button Thread.sleep(2000); // sleep has only been used to showcase each event separately robot.keyPress(KeyEvent.VK_TAB); Thread.sleep(2000);//from w ww . ja va2s. c o m robot.keyPress(KeyEvent.VK_TAB); Thread.sleep(2000); robot.keyPress(KeyEvent.VK_TAB); Thread.sleep(2000); robot.keyPress(KeyEvent.VK_ENTER); //readXLSXFile(); //System.out.println(uploadtext.getText()); }
From source file:jp.co.nssol.h5.test.selenium.base.H5TestCase.java
License:Apache License
/** * webdrier_config.xml?testPageUrl???????????? * * @param url/*from ww w . j a va 2s .c om*/ */ protected static void show(String relativeUrl) { try { final URL url = new URL(new URL(TEST_PAGE_URL), relativeUrl); new WebDriverWait(driver, 10).until(new ExpectedCondition<Boolean>() { @Override public Boolean apply(WebDriver d) { d.get(url.toString()); return d.getCurrentUrl().equals(url.toString()); } }); } catch (MalformedURLException e) { e.printStackTrace(); } }
From source file:litecartAdmin.GeoZonesPageTest.java
@Parameters public static Collection<Object[]> getAllUrl() { WebDriver driver = getDriver(); (new AdminLoginPage(driver)).login(); driver.get("http://litecart.resscode.org.ua/admin/?app=geo_zones&doc=geo_zones"); List<WebElement> elems = driver.findElements(By.cssSelector(".row td:nth-child(3) a")); List<Object[]> hrefs = new ArrayList<Object[]>(); elems.forEach((e) -> {/* w w w. j av a 2 s .c o m*/ hrefs.add(new Object[] { e.getAttribute("href") }); }); driver.quit(); return hrefs; }
From source file:marmotinni.MarmotinniRunner.java
License:Apache License
public static void main(String[] args) { ArrayList<String> scripts = new ArrayList<String>(); Map<String, String> argsMap = new HashMap<String, String>(); for (String arg : args) { String[] keyValuePair = arg.split("="); if (keyValuePair[0].equals("script")) scripts.add(keyValuePair[1]); else//from w w w . ja v a 2 s .co m argsMap.put(keyValuePair[0], keyValuePair[1]); } final String showScriptsArg = argsMap.get("showScripts"); TestStep.showScripts = showScriptsArg != null && showScriptsArg.equalsIgnoreCase("true"); final String showStepsArg = argsMap.get("showSteps"); TestCase.showSteps = showStepsArg != null && showStepsArg.equalsIgnoreCase("true"); final String url = argsMap.get("url"); System.out.println(url); final String browser = argsMap.get("browser"); WebDriver driver; if (browser != null && browser.equalsIgnoreCase("chrome")) driver = new ChromeDriver(); else driver = new FirefoxDriver(); driver.get(url); int exitCode = 0; try { MarmotinniRunner mr = new MarmotinniRunner(); final String verboseXMLParsingArg = argsMap.get("verboseXMLParsing"); mr.verboseXMLParsing = verboseXMLParsingArg != null && verboseXMLParsingArg.equalsIgnoreCase("true"); int n = scripts.size(); for (int i = 0; i < n; i++) { if (!mr.runTest(driver, scripts.get(i))) { System.out.println("script failed"); exitCode = 1; } } } catch (Exception e) { System.out.println(e.getMessage()); exitCode = 1; } finally { driver.quit(); } System.exit(exitCode); }
From source file:melihovv.AvitoNewMessageChecker.AvitoNewMessageChecker.java
License:Open Source License
public static void main(String[] args) { final Logger log = LogManager.getLogger(AvitoNewMessageChecker.class.getName()); if (args.length != 1) { log.fatal("? config.yaml"); }/*from w w w. java 2 s . c om*/ YamlReader reader = null; try { reader = new YamlReader(new FileReader(args[0])); } catch (FileNotFoundException e) { log.fatal("? config.yaml"); log.fatal(e.getMessage()); System.exit(1); } Map config = null; try { Object temp = reader.read(); config = (Map) temp; } catch (YamlException e) { log.fatal(" ??? config.yaml"); log.fatal(e.getMessage()); System.exit(1); } final List<String> keys = Arrays.asList("avito_login", "avito_pass", "smtp_host", "smtp_port", "smtp_login", "smtp_pass", "email_from", "email_to"); for (final String key : keys) { if (!config.containsKey(key)) { String values = String.join(", ", keys); log.fatal("- : " + values); System.exit(1); } } try { final WebDriver driver = new FirefoxDriver(); final String baseUrl = "https://www.avito.ru/"; driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); driver.get(baseUrl + "profile/login"); driver.findElement(By.name("login")).clear(); driver.findElement(By.name("login")).sendKeys(config.get("avito_login").toString()); driver.findElement(By.name("password")).clear(); driver.findElement(By.name("password")).sendKeys(config.get("avito_pass").toString()); driver.findElement(By.xpath("//button[@type='submit']")).click(); driver.findElement(By.cssSelector("#sidebar-nav-messenger > " + "a.link.js-sidebar-menu-link")).click(); final boolean newMessagesPresent = isElementPresent(driver, By.className("is-design-new")); driver.get(baseUrl + "profile/exit"); driver.quit(); if (newMessagesPresent) { log.info("? ??"); sendNotification(config.get("smtp_host").toString(), config.get("smtp_port").toString(), config.get("smtp_login").toString(), config.get("smtp_pass").toString(), config.get("email_from").toString(), config.get("email_to").toString(), "New message on avito.ru", "You have unread messages on avito.ru"); } else { log.info("? ? "); } } catch (Exception e) { log.error("- "); log.error(e.getMessage()); log.error(Arrays.toString(e.getStackTrace())); System.exit(1); } }
From source file:net.atf4j.webdriver.BrowserFactoryTest.java
License:Open Source License
/** * Verify that verify page loaded.//w ww .ja v a2s . c o m * * @param webDriver the web driver */ private void verifyPageLoaded(final WebDriver webDriver) { webDriver.get(TEST_URL); final String currentUrl = webDriver.getCurrentUrl(); this.log.info(currentUrl); final String pageTitle = webDriver.getTitle(); this.log.info(pageTitle); }
From source file:net.atf4j.webdriver.WebDriverSmokeTest.java
License:Open Source License
private void verifyTomcatPresent(final WebDriver webDriver) { TestContext.assumeLocalServer();/* w w w. ja v a 2 s .c o m*/ webDriver.get("http://127.0.0.1:8080/"); final String pageTitle = webDriver.getTitle(); verifyNotNull(pageTitle); assertTrue(pageTitle.contains("Apache Tomcat")); this.log.info("pageTitle = {}", pageTitle); }
From source file:net.integration.StartPage.java
License:Open Source License
public StartPage(WebDriver webDriver) { this.webDriver = webDriver; webDriver.get("http://localhost:8080/cmf/cmf/"); ((JavascriptExecutor) webDriver).executeScript("window.resizeTo(1024, 768)"); pause(500);/*from w ww. j a v a 2s. c om*/ }
From source file:net.javacrumb.webview.webdriver.SimpleTest.java
License:Apache License
public static void main(String[] args) throws InterruptedException { // Create a new instance of the html unit driver // Notice that the remainder of the code relies on the interface, // not the implementation. // WebDriver driver = new FirefoxDriver(); WebDriver driver = new WebViewDriver(); // And now use this to visit Google driver.get("http://www.google.com"); // Find the text input element by its name WebElement element = driver.findElement(By.name("q")); // Enter something to search for element.sendKeys("Cheese!"); // Now submit the form. WebDriver will find the form for us from the element element.submit();/*from www . ja v a2s .c o m*/ // // // Check the title of the page // System.out.println("Page title is: " + driver.getTitle()); // // driver.quit(); }