List of usage examples for org.openqa.selenium.chrome ChromeDriver ChromeDriver
public ChromeDriver()
From source file:com.demo.selenium.example.ChromeExmple.java
License:Apache License
@Test public void chromeTest() throws InterruptedException { System.setProperty("webdriver.chrome.driver", "C:/chromedriver.exe"); WebDriver driver = new ChromeDriver(); driver.get("http://www.google.com"); Thread.sleep(5000);// w ww .j a v a 2 s . c o m driver.close(); }
From source file:com.digi.selenium.util.common.PageNavigation.java
protected void setUpDriver() { //load the configuration file loadSetUpConfig();//from w w w . ja v a2 s . co m log.info("DriverClass : " + DRIVER_CLASS); DRIVER_CLASS = prop.getProperty("DRIVER_CLASS"); String DRIVER_LOC = prop.getProperty("DRIVER_LOCATION"); //try{ System.setProperty(DRIVER_CLASS, DRIVER_LOC); /*System.out.println("DRIVER_CLASS : " +DRIVER_CLASS ); System.out.println("DRIVER_LOC : " +DRIVER_LOC ); */ driver = new ChromeDriver(); // Put a Implicit wait, this means that any search for elements on the page waitForPageLoad(30); //maximize the browser window driver.manage().window().maximize(); //set the driver for Listerner class - captures the ScreenShot setSsWebSriver(getDriver()); log.info("Success : Driver Initialized Successfully"); }
From source file:com.digi.selenium.util.PageNavigation.java
protected void setUpDriver() { //load the configuration file loadSetUpConfig();/*from w w w .jav a2 s. c o m*/ log.info("DriverClass : "); DRIVER_CLASS = prop.getProperty("DRIVER_CLASS"); String DRIVER_LOC = prop.getProperty("DRIVER_LOCATION"); //try{ System.setProperty(DRIVER_CLASS, DRIVER_LOC); /*System.out.println("DRIVER_CLASS : " +DRIVER_CLASS ); System.out.println("DRIVER_LOC : " +DRIVER_LOC ); */ driver = new ChromeDriver(); // Put a Implicit wait, this means that any search for elements on the page waitForPageLoad(60); //maximize the browser window driver.manage().window().maximize(); //set the driver for Listerner class - captures the ScreenShot setSsWebSriver(getDriver()); log.info("Success : Driver Initialized Successfully"); }
From source file:com.ecfeed.core.runner.java.SeleniumTestMethodInvoker.java
License:Open Source License
private void setDriverIntr(String browserName, String driverPath, MethodParameterNode methodParameterNode) { if (StringHelper.isEqualIgnoreCase(browserName, NodePropertyDefs.browserNameChrome())) { System.setProperty("webdriver.chrome.driver", driverPath); fDriver = new ChromeDriver(); return;//from w ww . j ava 2 s . c o m } if (StringHelper.isEqualIgnoreCase(browserName, NodePropertyDefs.browserNameFirefox())) { System.setProperty("webdriver.gecko.driver", driverPath); fDriver = new FirefoxDriver(); return; } if (StringHelper.isEqualIgnoreCase(browserName, NodePropertyDefs.browserNameIExplorer())) { System.setProperty("webdriver.ie.driver", driverPath); fDriver = new InternetExplorerDriver(); return; } if (StringHelper.isEqualIgnoreCase(browserName, NodePropertyDefs.browserNameOpera())) { System.setProperty("webdriver.opera.driver", driverPath); fDriver = new OperaDriver(); return; } if (StringHelper.isEqualIgnoreCase(browserName, NodePropertyDefs.browserNameSafari())) { fDriver = new SafariDriver(); return; } reportException("WebDriver is not supported: " + browserName + ".", methodParameterNode); }
From source file:com.ecofactor.qa.automation.util.mail.GmailForNewUser.java
License:Open Source License
/** * Gets the changed password./*from w w w . jav a 2s . c o m*/ * @param url the url * @param emailUserName the email user name * @param emailPassword the email password * @param subject the subject * @param boldIndex the bold index * @param pwdIndex the pwd index * @return the changed password */ public String getChangedPassword(String url, String emailUserName, String emailPassword, String subject, int boldIndex, int pwdIndex) { if (gmailDriver == null) { gmailDriver = new ChromeDriver(); } String tempPassword = null; largeWait(); DriverConfig.setLogString("Load Email portal URL at change password", true); DriverConfig.setLogString("URL : " + url + "" + emailUserName, true); gmailDriver.navigate().to(url + "" + emailUserName); largeWait(); boolean session = isDisplayedById(gmailDriver, "Passwd", MEDIUM_TIMEOUT); if (session) { DriverConfig.setLogString( "Enter username and password for Email(" + emailUserName + "/" + emailPassword + ")", true); if (isDisplayedById(gmailDriver, "reauthEmail", SHORT_TIMEOUT) && gmailDriver.findElement(By.id("reauthEmail")).getText().equalsIgnoreCase(emailUserName)) { clearAndInput(gmailDriver, By.id("Passwd"), emailPassword); } else { clearAndInput(gmailDriver, By.id("Email"), emailUserName); clearAndInput(gmailDriver, By.id("Passwd"), emailPassword); } mediumWait(); WebElement signInButtonElement = gmailDriver.findElement(By.id("signIn")); DriverConfig.setLogString("click Sign In button", true); signInButtonElement.click(); largeWait(); boolean button = isDisplayedById(gmailDriver, "no-button", MEDIUM_TIMEOUT); if (button) { WebElement buttonElement = gmailDriver.findElement(By.id("no-button")); buttonElement.click(); mediumWait(); } } isDisplayedByCSS(gmailDriver, ".aio.UKr6le", MEDIUM_TIMEOUT); DriverConfig.setLogString("Click Inbox.", true); WebElement inboxElement = gmailDriver.findElement(By.partialLinkText("Inbox")); inboxElement.click(); largeWait(); DriverConfig.setLogString("Click Subject of Email.", true); DriverConfig.setLogString("Subject of Email : " + subject, true); WebElement webElement = gmailDriver.findElement(By.cssSelector(".ae4.UI.UJ")); List<WebElement> tagElement = webElement.findElements(By.tagName(TAG_BOLD)); WebElement firstElement = tagElement.get(0); if (firstElement != null && firstElement.isDisplayed() && firstElement.getText().equalsIgnoreCase(subject)) { firstElement.click(); largeWait(); } DriverConfig.setLogString("Get temporary Password/activation link from Email.", true); if (boldIndex == 1) { WebElement divBodyElement = gmailDriver.findElement(By.xpath("//*[contains(@class,'adO')]")); if (pwdIndex == 1) { WebElement pwdElement = divBodyElement.findElements(By.tagName(TAG_STRONG)).get(0); tempPassword = pwdElement.getText(); DriverConfig.setLogString("Temporary password got from email " + tempPassword, true); } else { WebElement pwdElement = divBodyElement.findElements(By.tagName(TAG_ANCHOR)).get(0); tempPassword = pwdElement.getText(); DriverConfig.setLogString("Activation link got from email " + tempPassword, true); } } else if (boldIndex == 0) { DriverConfig.setLogString("Header Tag", true); WebElement divBodyElement = gmailDriver.findElement(By.className("gs")); List<WebElement> headerElement = divBodyElement.findElements(By.tagName("strong")); for (WebElement webelement : headerElement) { if (webelement.isDisplayed()) { tempPassword = webelement.getText(); DriverConfig.setLogString("Temporary password got from email " + tempPassword, true); } } } mediumWait(); deleteFirstMail(gmailDriver); DriverConfig.setLogString("Click user for Signout option", true); boolean value = isDisplayedById(gmailDriver, "gbgs4dn", MEDIUM_TIMEOUT); DriverConfig.setLogString("User name displayed for sign out : " + value, true); if (value) { gmailDriver.findElement(By.id("gbgs4dn")).click(); } else { WebElement signOutElement = gmailDriver.findElement(By.partialLinkText(emailUserName)); signOutElement.click(); } smallWait(); DriverConfig.setLogString("Click Signout", true); gmailDriver.findElement(By.id("gb_71")).click(); mediumWait(); mediumWait(); gmailDriver.close(); gmailDriver.quit(); gmailDriver = null; return tempPassword; }
From source file:com.ecofactor.qa.automation.util.mail.GmailForNewUser.java
License:Open Source License
/** * Delete old mails./*from w w w.j a v a2 s. c o m*/ * @param url the url * @param emailUserName the email user name * @param emailPassword the email password * @param subject the subject */ public void deleteOldMails(String url, String emailUserName, String emailPassword, String subject) { if (gmailDriver == null) { // driverConfig.loadDriver(); gmailDriver = new ChromeDriver(); } largeWait(); DriverConfig.setLogString("Load Email portal URL.", true); DriverConfig.setLogString("URL : " + url, true); gmailDriver.navigate().to(url); // driver.navigate().to(url + "" + emailUserName); largeWait(); boolean session = isDisplayedById(gmailDriver, "Passwd", MEDIUM_TIMEOUT); if (session) { DriverConfig.setLogString( "Enter username and password for Email(" + emailUserName + "/" + emailPassword + ")", true); gmailDriver.findElement(By.id("Email")).sendKeys(emailUserName); gmailDriver.findElement(By.id("Passwd")).sendKeys(emailPassword); mediumWait(); WebElement signInButtonElement = gmailDriver.findElement(By.id("signIn")); DriverConfig.setLogString("click Sign In button", true); signInButtonElement.click(); largeWait(); boolean button = isDisplayedById(gmailDriver, "no-button", MEDIUM_TIMEOUT); if (button) { WebElement buttonElement = gmailDriver.findElement(By.id("no-button")); buttonElement.click(); mediumWait(); } } isDisplayedByCSS(gmailDriver, ".aio.UKr6le", MEDIUM_TIMEOUT); deleteFirstMail(gmailDriver); DriverConfig.setLogString("Click user for Signout option", true); boolean value = isDisplayedById(gmailDriver, "gbgs4dn", MEDIUM_TIMEOUT); DriverConfig.setLogString("User name displayed for sign out : " + value, true); if (value) { gmailDriver.findElement(By.id("gbgs4dn")).click(); } else { WebElement signOutElement = gmailDriver.findElement(By.partialLinkText(emailUserName)); signOutElement.click(); } smallWait(); DriverConfig.setLogString("Click Signout", true); gmailDriver.findElement(By.id("gb_71")).click(); mediumWait(); mediumWait(); gmailDriver.close(); gmailDriver.quit(); gmailDriver = null; }
From source file:com.esprit.GUI.Login.java
private void fbActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fbActionPerformed // TODO add your handling code here: String accessToken = ""; System.setProperty("webdriver.chrome.driver", "D:\\security\\chromedriver.exe"); WebDriver driver = new ChromeDriver(); driver.get(/*w w w.jav a2s. c o m*/ "https://graph.facebook.com/oauth/authorize?type=user_agent&client_id=182538538804902&redirect_uri=https://www.google.tn/&scope=user_about_me," + "user_actions.books,user_actions.fitness,user_actions.music,user_actions.news,user_actions.video,user_activities,user_birthday,user_education_history," + "user_events,user_friends,user_games_activity,user_groups,user_hometown,user_interests,user_likes,user_location,user_photos,user_relationship_details," + "user_relationships,user_religion_politics,user_status,user_tagged_places,user_videos,user_website,user_work_history,ads_management,ads_read,email," + "manage_notifications,manage_pages,publish_actions,read_friendlists,read_insights,read_mailbox,read_page_mailboxes,read_stream,rsvp_event"); while (true) { if (!driver.getCurrentUrl().contains("facebook.com")) { String url = driver.getCurrentUrl(); int state = 0; for (int i = 0; i < url.length(); i++) { switch (state) { case (0): { if (url.charAt(i) == '=') { state = 1; } } break; case (1): { if (url.charAt(i) == '&') { state = 2; } else { accessToken += url.charAt(i); } } break; case (2): { } break; } } driver.quit(); System.out.println(accessToken); FacebookClient fbClient = new DefaultFacebookClient(accessToken); User me = fbClient.fetchObject("me", User.class); txt_password.setText(me.getName()); txt_mail.setText(me.getId()); } } }
From source file:com.esprit.GUI.Register1.java
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed // TODO add your handling code here: String accessToken = ""; System.setProperty("webdriver.chrome.driver", "D:\\security\\chromedriver.exe"); WebDriver driver = new ChromeDriver(); driver.get(// w w w .j av a2s .co m "https://graph.facebook.com/oauth/authorize?type=user_agent&client_id=1685522955036652&redirect_uri=https://www.google.tn/&scope=user_about_me," + "user_actions.books,user_actions.fitness,user_actions.music,user_actions.news,user_actions.video,user_activities,user_birthday,user_education_history," + "user_events,user_friends,user_games_activity,user_groups,user_hometown,user_interests,user_likes,user_location,user_photos,user_relationship_details," + "user_relationships,user_religion_politics,user_status,user_tagged_places,user_videos,user_website,user_work_history,ads_management,ads_read,email," + "manage_notifications,manage_pages,publish_actions,read_friendlists,read_insights,read_mailbox,read_page_mailboxes,read_stream,rsvp_event"); while (true) { if (!driver.getCurrentUrl().contains("facebook.com")) { String url = driver.getCurrentUrl(); int state = 0; for (int i = 0; i < url.length(); i++) { switch (state) { case (0): { if (url.charAt(i) == '=') { state = 1; } } break; case (1): { if (url.charAt(i) == '&') { state = 2; } else { accessToken += url.charAt(i); } } break; case (2): { } break; } } driver.quit(); System.out.println(accessToken); FacebookClient fbClient = new DefaultFacebookClient(accessToken); User me = fbClient.fetchObject("me", User.class); txtno.setText(me.getFirstName()); txtpr.setText(me.getLastName()); txtma.setText(me.getEmail()); pwd.setText(me.getName()); txtid.setText(me.getId()); } } }
From source file:com.example.selenium.data.driven.CSVDataReader.java
@BeforeTest public void setup() { System.setProperty("webdriver.chrome.driver", "D:\\workspace\\TechnicalConsultent\\Selenium\\software\\chromedriver.exe"); driver = new ChromeDriver(); driver.get("http://localhost:8080/WebApplication/pages/forms.html"); }
From source file:com.example.tests.CadastroChromeTest.java
@Before public void setUp() throws Exception { System.setProperty("webdriver.chrome.driver", "/home/camille/Downloads/chromedriver"); driver = new ChromeDriver(); driver.get("http://localhost:8080/"); driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); }