List of usage examples for org.openqa.selenium.firefox FirefoxDriver FirefoxDriver
public FirefoxDriver()
From source file:com.vha.techdev.webapp.test.SimpleTest.java
License:Apache License
@Before public void setup() throws Exception { this.serverUrl = System.getProperty("serverUrl", "http://localhost:9090/"); if (!serverUrl.endsWith("/")) { serverUrl += "/"; }// ww w. j a v a2 s . co m this.driver = new FirefoxDriver(); }
From source file:com.vilt.minium.script.test.WebElementsDriverConfig.java
License:Apache License
@Bean(destroyMethod = "quit") public DefaultWebElementsDriver wd() throws MalformedURLException { String remoteWebDriverUrl = System.getProperty("remote.web.driver.url"); WebDriver webDriver;//from www . ja v a 2 s. c om if (remoteWebDriverUrl != null) { webDriver = new RemoteWebDriver(new URL(remoteWebDriverUrl), DesiredCapabilities.chrome()); webDriver = new Augmenter().augment(webDriver); } else { try { webDriver = new ChromeDriver(); } catch (Exception e) { if (LOGGER.isDebugEnabled()) { LOGGER.debug( "Chrome driver not found or could not be launched, using Firefox driver instead (set log level to debug to check the exception)", e); } else { LOGGER.warn( "Chrome driver not found or could not be launched, using Firefox driver instead (set log level to debug to check the exception)"); } webDriver = new FirefoxDriver(); } } return new DefaultWebElementsDriver(webDriver); }
From source file:com.vmware.gemfire.tools.pulse.testbed.driver.PulseUITest.java
License:Apache License
@BeforeClass public static void setUpJetty() throws Exception { String host = InetAddress.getLocalHost().getHostAddress(); int port = 8080; String context = "/pulse"; path = getPulseWarPath();/* ww w .j av a 2 s. co m*/ //System.setProperty("pulse.propMockDataUpdaterClass", "com.vmware.gemfire.tools.pulse.testbed.PropMockDataUpdater"); jetty = JettyHelper.initJetty(host, port, false, false, null, null, null); JettyHelper.addWebApplication(jetty, context, getPulseWarPath()); jetty.start(); pulseURL = "http://" + host + ":" + port + context; Thread.sleep(1000); //wait till tomcat settles down driver = new FirefoxDriver(); driver.manage().window().maximize();//required to make all elements visible Thread.sleep(5000); //wait till pulse starts polling threads... testBed = new TestBed(); loginToPulse(driver, userName, pasword); }
From source file:com.vmware.gemfire.tools.pulse.tests.PulseAbstractTest.java
License:Apache License
public static void setUpServer(String username, String password, String jsonAuthFile) throws Exception { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); jmxPropertiesFile = classLoader.getResource("test.properties").getPath(); path = getPulseWarPath();//from w ww .j av a 2s . c o m server = Server.createServer(9999, jmxPropertiesFile, jsonAuthFile); String host = "localhost"; int port = 8080; String context = "/pulse"; jetty = JettyHelper.initJetty(host, port, false, false, null, null, null); JettyHelper.addWebApplication(jetty, context, getPulseWarPath()); jetty.start(); pulseURL = "http://" + host + ":" + port + context; Awaitility.await().until(() -> jetty.isStarted()); driver = new FirefoxDriver(); driver.manage().window().maximize(); driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS); driver.get(pulseURL); WebElement userNameElement = driver.findElement(By.id("user_name")); WebElement passwordElement = driver.findElement(By.id("user_password")); userNameElement.sendKeys(username); passwordElement.sendKeys(password); passwordElement.submit(); Thread.sleep(3000); WebElement userNameOnPulsePage = (new WebDriverWait(driver, 10)).until(new ExpectedCondition<WebElement>() { @Override public WebElement apply(WebDriver d) { return d.findElement(By.id("userName")); } }); assertNotNull(userNameOnPulsePage); driver.navigate().refresh(); Thread.sleep(7000); }
From source file:com.vmware.gemfire.tools.pulse.tests.PulseTest.java
License:Apache License
@BeforeClass public static void setUpBeforeClass() throws Exception { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); jmxPropertiesFile = classLoader.getResource("test.properties").getPath(); path = getPulseWarPath();/*from www. java2s.c o m*/ server = Server.createServer(9999, jmxPropertiesFile); String host = "localhost";// InetAddress.getLocalHost().getHostAddress(); int port = 8080; String context = "/pulse"; jetty = JettyHelper.initJetty(host, port, false, false, null, null, null); JettyHelper.addWebApplication(jetty, context, getPulseWarPath()); jetty.start(); pulseURL = "http://" + host + ":" + port + context; Thread.sleep(5000); // wait till the container settles down driver = new FirefoxDriver(); driver.manage().window().maximize(); driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS); driver.get(pulseURL); WebElement userNameElement = driver.findElement(By.id("user_name")); WebElement passwordElement = driver.findElement(By.id("user_password")); userNameElement.sendKeys(userName); passwordElement.sendKeys(pasword); passwordElement.submit(); Thread.sleep(3000); WebElement userNameOnPulsePage = (new WebDriverWait(driver, 10)).until(new ExpectedCondition<WebElement>() { @Override public WebElement apply(WebDriver d) { return d.findElement(By.id("userName")); } }); Assert.assertNotNull(userNameOnPulsePage); driver.navigate().refresh(); Thread.sleep(7000); }
From source file:com.webdriver1.MouseOver.java
public static void main(String[] args) throws InterruptedException { WebDriver driver = new FirefoxDriver(); //maximize window driver.manage().window().maximize(); //wait for page load driver.manage().timeouts().implicitlyWait(40, TimeUnit.SECONDS); //Go to URL/*from w ww . j a va 2 s . co m*/ driver.get("http://flex.apache.org/"); //Get web element WebElement element = driver.findElement(By.xpath("//ul[@id='nav']/li[2]/a")); //Thread.sleep(1000); //Get sub web element/html/body/div[1]/div[1]/ WebElement element1 = driver.findElement(By.xpath("//a[contains(text(),'License & Trademarks')]")); //Declare Actions Object Actions action = new Actions(driver); //Mouse over on element items action.moveToElement(element).build().perform(); //wait for items Thread.sleep(2000); //click on element1 items action.moveToElement(element1).clickAndHold().build().perform(); }
From source file:com.winhong.dagger.BrowserEmulator.java
License:Apache License
private void setupBrowserCoreType(int type) { if (type == 1) { browserCore = new FirefoxDriver(); logger.info("Using Firefox"); return;// w w w . ja v a 2 s.c o m } if (type == 2) { chromeServer = new ChromeDriverService.Builder() .usingDriverExecutable(new File(GlobalSettings.chromeDriverPath)).usingAnyFreePort().build(); try { chromeServer.start(); } catch (IOException e) { e.printStackTrace(); } DesiredCapabilities capabilities = DesiredCapabilities.chrome(); String prox = GlobalSettings.prop.getProperty("http_proxy"); if (prox != null) { capabilities.setCapability("chrome.switches", Arrays.asList("--start-maximized", "--proxy-server=" + prox)); } else { capabilities.setCapability("chrome.switches", Arrays.asList("--start-maximized")); } browserCore = new RemoteWebDriver(chromeServer.getUrl(), capabilities); logger.info("Using Chrome"); return; } if (type == 3) { System.setProperty("webdriver.ie.driver", GlobalSettings.ieDriverPath); DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer(); capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true); browserCore = new InternetExplorerDriver(capabilities); logger.info("Using IE"); return; } if (type == 4) { browserCore = new SafariDriver(); logger.info("Using Safari"); return; } Assert.fail("Incorrect browser type"); }
From source file:com.zaizi.automation.abfts.drivers.FirefoxDriverStore.java
License:Open Source License
/** * @return */ public FirefoxDriver createWebDriver() { driver = new FirefoxDriver(); return driver; }
From source file:com.zhao.crawler.util.CookieUtil.java
License:Open Source License
/** * csdn??cookies?/*from w w w.j a va2 s.c o m*/ * * @param username * ?? * @param password * ? * @param geckodriverpath * gecko?https://github.com/mozilla/geckodriver * @param savecookiepath * cookies? * @throws Exception */ public static void firfoxDriverGetCookies(String username, String password, String geckodriverpath, String savecookiepath) throws Exception { // ??? System.setProperty("webdriver.gecko.driver", geckodriverpath); FirefoxDriver driver = new FirefoxDriver(); String baseUrl = "http://kaixin65.com/member.php?mod=logging&action=login&infloat=yes&handlekey=login&inajax=1&ajaxtarget=fwin_content_login"; // url driver.get(baseUrl); // ? driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); // ?? WebElement elemUsername = driver.findElement(By.name("username")); WebElement elemPassword = driver.findElement(By.name("password")); WebElement btn = driver.findElement(By.className("logging")); WebElement rememberMe = driver.findElement(By.id("rememberMe")); // ?? elemUsername.sendKeys(username); elemPassword.sendKeys(password); rememberMe.click(); // ??? btn.submit(); Thread.sleep(5000); driver.get("http://msg.csdn.net/"); Thread.sleep(5000); // ?cookies driver.manage().getCookies(); Set<org.openqa.selenium.Cookie> cookies = driver.manage().getCookies(); System.out.println("Size: " + cookies.size()); Iterator<org.openqa.selenium.Cookie> itr = cookies.iterator(); CookieStore cookieStore = new BasicCookieStore(); while (itr.hasNext()) { Cookie cookie = itr.next(); BasicClientCookie bcco = new BasicClientCookie(cookie.getName(), cookie.getValue()); bcco.setDomain(cookie.getDomain()); bcco.setPath(cookie.getPath()); cookieStore.addCookie(bcco); } // ? ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(new File(savecookiepath))); oos.writeObject(cookieStore); oos.close(); }
From source file:com.zuhlke.aztec.selenium.money.SellerRegistrationTest.java
@BeforeClass public static void classSetUp() throws ConfigurationException { //Driver setup driver = new FirefoxDriver(); driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS); //Open properties file PropertiesConfiguration moneyConfig = new PropertiesConfiguration(PROP_DIR + "/" + MONEY_PROP_FILE); //Global variables setup email = moneyConfig.getProperty("email").toString(); emailPw = moneyConfig.getProperty("pw").toString(); subject = moneyConfig.getProperty("subject").toString(); }