List of usage examples for org.openqa.selenium.ie InternetExplorerDriver InternetExplorerDriver
public InternetExplorerDriver()
From source file:scormADL12.java
License:Open Source License
@Before public void setUp() { driver = new InternetExplorerDriver(); wait = new WebDriverWait(driver, 60); }
From source file:scormADL2004.java
License:Open Source License
@Before public void setUp() throws IOException, InterruptedException { driver = new InternetExplorerDriver(); wait = new WebDriverWait(driver, 60); String testSuiteURL = System.getProperty("testSuiteURL"); String moodleURL = System.getProperty("moodleURL"); if (testSuiteURL == null) { throw new IOException("ADL SCORM 2004 Test Suite URL not specified"); }//from ww w . ja v a2 s . co m if (moodleURL == null) { throw new IOException("Moodle Test Site URL not specified"); } if (username1 == null) { username1 = "joestudent"; password1 = "joestudent"; } if (username2 == null) { username2 = "marylearner"; password2 = "marylearner"; } driver.get(testSuiteURL); // Overcome Selenium IE Page load Bug. driver.switchTo().frame("instructions"); wait.until(presenceOfElementLocated(By.id("New"))); ((JavascriptExecutor) driver).executeScript("newTest();"); wait.until(presenceOfElementLocated(By.id("pname"))); driver.findElement(By.id("pname")).sendKeys("Moodle"); driver.findElement(By.id("pversion")).sendKeys("2011033003"); driver.findElement(By.id("pvname")).sendKeys("MoodleHQ"); driver.switchTo().window(""); driver.switchTo().frame("controls"); driver.findElement(By.id("continue")).click(); driver.switchTo().window(""); driver.switchTo().frame("instructions"); wait.until(presenceOfElementLocated(By.id("learner1Name"))); driver.findElement(By.id("learner1Name")).sendKeys("Moodle Learner 1"); driver.findElement(By.id("learner1ID")).sendKeys(username1); driver.findElement(By.id("learner2Name")).sendKeys("Moodle Learner 2"); driver.findElement(By.id("learner2ID")).sendKeys(username2); driver.switchTo().window(""); driver.switchTo().frame("controls"); driver.findElement(By.id("continue")).click(); driver.switchTo().window(""); ((JavascriptExecutor) driver).executeScript("window.open('" + moodleURL + "', 'moodleWindow');"); driver.switchTo().window("moodleWindow"); }
From source file:openCloseTables.java
public static void main(String[] args) throws IOException { System.setProperty("webdriver.ie.driver", "C:\\Users\\Colin Cook\\Desktop\\selenium-2.53.1\\IEDriverServer.exe"); WebDriver driver = new InternetExplorerDriver(); driver.get("http://10.0.1.53/opstar_test/"); out.println("Launching Internet Explorer browser.."); driver.manage().window().maximize(); try {//from w w w .j a v a 2 s .c o m Thread.sleep(3000); // pauses for 3 seconds } catch (InterruptedException e) { e.printStackTrace(); } out.println("The title of the page being tested is: " + driver.getTitle()); WebElement acknowledge = driver .findElement(By.xpath("html/body/div[5]/div[1]/div[2]/div[2]/div[1]/div/div[2]/center/a")); acknowledge.click(); //first popup when you go on site try { Thread.sleep(3000); } catch (InterruptedException e) { e.printStackTrace(); } WebElement applications = //driver.findElement(By.xpath("html/body/div[3]/div[2]/div/div[1]/ul[2]/li[5]/a/span")); driver.findElement(By.linkText("Applications")); applications.click(); WebElement toTools = driver .findElement(By.xpath("html/body/div[3]/div[2]/div/div[1]/ul[2]/li[7]/ul/li[2]/a")); toTools.click(); try { Thread.sleep(3000); } catch (InterruptedException e) { e.printStackTrace(); } WebElement traingFolder = driver .findElement(By.xpath("html/body/div[3]/div[2]/div/div[1]/ul[2]/li[7]/ul/li[2]/ul/li/a")); traingFolder.click(); try { Thread.sleep(3000); } catch (InterruptedException e) { e.printStackTrace(); } WebElement closeBox = driver.findElement(By.id("cboxClose")); closeBox.click(); //clicks second popup acknolwedge box try { Thread.sleep(3000); } catch (InterruptedException e) { e.printStackTrace(); } WebElement textBox = driver.findElement(By .xpath("html/body/div[3]/div[4]/div[2]/div/div[1]/div/div[2]/div/form/div/div/span/span[1]/span")); textBox.click(); textBox.sendKeys("ken"); //first three letters of someones name try { Thread.sleep(3000); } catch (InterruptedException e) { e.printStackTrace(); } textBox.sendKeys(Keys.ENTER); try { Thread.sleep(3000); } catch (InterruptedException e) { e.printStackTrace(); } WebElement table1 = driver.findElement( By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[1]/div/div[1]/div/a[2]")); table1.click(); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } table1.click(); out.println("The Designations folder has been successfully opened and closed"); try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } WebElement table2 = driver.findElement( By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[2]/div/div[1]/div/a[2]")); table2.click(); try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } table2.click(); out.println("The Waivers folder has been successfully opened and closed"); try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } WebElement table3 = driver.findElement( By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[3]/div/div[1]/div/a[2]")); table3.click(); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } table3.click(); out.println("The Professional Licenses/ Certificates / Medical folder has been opened and closed"); try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } WebElement table4 = driver.findElement( By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[4]/div/div[1]/div/a[2]")); table4.click(); try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } table4.click(); out.println("The First Aid folder has been succesfully opened and closed"); try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } WebElement table5 = driver.findElement( By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[5]/div/div[1]/div/a[2]")); table5.click(); try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } table5.click(); out.println("The Star folder has been successfully opened and closed"); try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } WebElement table6 = driver.findElement( By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[6]/div/div[1]/div/a[2]")); table6.click(); try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } table6.click(); out.println("The Training Courses and Tests folder has been successfully opened and closed"); try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } WebElement table7 = driver.findElement( By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[7]/div/div[1]/div/a[2]")); table7.click(); try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } table7.click(); out.println( "The Professional Development / Individual Development Plan folder has been successfully opened and closed"); try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } WebElement table8 = driver.findElement( By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[8]/div/div[1]/div/a[2]")); table8.click(); try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } table8.click(); out.println("The FLETC Certificates folder has been successfully opened and closed"); try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } WebElement table9 = driver.findElement( By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[9]/div/div[1]/div/a[2]")); table9.click(); try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } table9.click(); out.println("The Miscellaneous folder has been succesfully opened and closed"); try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } WebElement qualifications = driver .findElement(By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[1]/div/div/div[1]/div/a[2]")); qualifications.click(); try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } qualifications.click(); out.println("The Qualifications folder has been successfully opened and closed"); // I should program test scripts like this in the future // try { // WebElement xbox = driver.findElement(By.id("cboxClose")); // xbox.click(); // } catch(Exception e) { // System.err.print("NO NO NO that "); // } }
From source file:ToTrainingFolder.java
public static void main(String[] args) throws IOException { System.setProperty("webdriver.ie.driver", "C:\\Users\\Colin Cook\\Desktop\\Opstar Training Folder\\IEDriverServer.exe"); WebDriver driver = new InternetExplorerDriver(); driver.get("http://10.0.1.53/opstar_test/"); out.println("Launching Internet Explorer browser.."); driver.manage().window().maximize(); try {/* w ww .j ava 2s . c om*/ Thread.sleep(1000); // pauses for 1 second } catch (InterruptedException e) { e.printStackTrace(); } out.println("The title of the page being tested is: " + driver.getTitle()); WebElement acknowledge = driver .findElement(By.xpath("html/body/div[5]/div[1]/div[2]/div[2]/div[1]/div/div[2]/center/a")); acknowledge.click(); //first popup when you go on site try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } WebElement applications = driver.findElement(By.xpath("html/body/div[3]/div[2]/div/div[1]/ul[2]/li[7]/a")); //driver.findElement(By.linkText("Training Folder")); System.out.println(applications.getText()); applications.click(); WebElement toTools = driver .findElement(By.xpath("html/body/div[3]/div[2]/div/div[1]/ul[2]/li[7]/ul/li[2]/a")); toTools.click(); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } WebElement traingFolder = driver .findElement(By.xpath("html/body/div[3]/div[2]/div/div[1]/ul[2]/li[7]/ul/li[2]/ul/li/a")); traingFolder.click(); System.out.println("The Training Folder has been selected"); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } WebElement closeBox = driver.findElement(By.id("cboxClose")); closeBox.click(); //clicks second popup acknolwedge box try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } WebElement textBox = driver.findElement(By .xpath("html/body/div[3]/div[4]/div[2]/div/div[1]/div/div[2]/div/form/div/div/span/span[1]/span")); textBox.click(); textBox.sendKeys("ken"); textBox.sendKeys(Keys.ENTER); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } /*************** THIS IS WHERE THE QUALIFICATIONS FOLDER STARTS ******************/ WebElement image1 = driver.findElement(By.xpath( "html/body/div[3]/div[4]/div[2]/div/div[2]/div[1]/div/div/div[2]/div[3]/div[3]/div[1]/div[1]/span/a/img")); image1.click(); image1.sendKeys(Keys.ESCAPE); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } WebElement table1 = driver.findElement(By.xpath( "html/body/div[3]/div[4]/div[2]/div/div[2]/div[1]/div/div/div[2]/div[3]/div[3]/div[1]/div[2]/input")); table1.clear(); table1.sendKeys("Testing table 1, Opstar Test"); try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } WebElement date1 = driver.findElement(By.xpath( "html/body/div[3]/div[4]/div[2]/div/div[2]/div[1]/div/div/div[2]/div[3]/div[3]/div[1]/div[3]/input")); date1.click(); date1.clear(); date1.sendKeys("12/25/2016"); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } // WebElement save = driver.findElement(By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[1]/div/div/div[2]/div[3]/div[3]/div[1]/div[5]/span[1]/i")); //save.click(); WebElement image2 = driver.findElement(By.xpath( "html/body/div[3]/div[4]/div[2]/div/div[2]/div[1]/div/div/div[2]/div[3]/div[3]/div[3]/div[1]/span/a/img")); image2.click(); image2.sendKeys(Keys.ESCAPE); try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } WebElement title2 = driver.findElement(By.xpath( "html/body/div[3]/div[4]/div[2]/div/div[2]/div[1]/div/div/div[2]/div[3]/div[3]/div[3]/div[2]/input")); title2.clear(); title2.sendKeys("Testing table 2, Opstar test 2"); try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } WebElement date2 = driver.findElement(By.xpath( "html/body/div[3]/div[4]/div[2]/div/div[2]/div[1]/div/div/div[2]/div[3]/div[3]/div[3]/div[3]/input")); date2.click(); date2.clear(); date2.sendKeys("01/01/2017"); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } // WebElement save2 = driver.findElement(By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[1]/div/div/div[2]/div[3]/div[3]/div[3]/div[5]/span[1]/i")); //save2.click(); WebElement closeQualifications = driver .findElement(By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[1]/div/div/div[1]/div/a[2]")); closeQualifications.click(); System.out.println("The Qualifications folder has been tested"); /*************** THIS IS WHERE THE DESIGNATIONS FOLDER STARTS ******************/ WebElement Designations = driver.findElement(By.xpath( "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[1]/div/div[2]/table/tbody/tr/td[1]/span/a/img")); Designations.click(); Designations.sendKeys(Keys.ESCAPE); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } WebElement DesignationsTitle = driver.findElement(By.xpath( "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[1]/div/div[2]/table/tbody/tr/td[2]/input")); DesignationsTitle.clear(); DesignationsTitle.sendKeys("Testing the Desiganations title box, Opstar Test"); WebElement DesignationsIssue = driver.findElement(By.xpath( "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[1]/div/div[2]/table/tbody/tr/td[3]/input")); DesignationsIssue.clear(); DesignationsIssue.sendKeys("03/24/2017"); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } // WebElement saveDesignations = driver.findElement(By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[1]/div/div[2]/table/tbody/tr/td[5]/span[1]/i")); //saveDesignations.click(); WebElement closeDesignations = driver .findElement(By.xpath(".//*[@id='student_folder_wrapper']/div[2]/div[1]/div/div[1]/div/a[2]")); closeDesignations.click(); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("The Designations box has been tested"); /*************** THIS IS WHERE THE WAIVERS FOLDER STARTS ******************/ WebElement waivers = driver.findElement( By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[2]/div/div[1]/div/a[2]")); waivers.click(); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } WebElement waiversFile = driver.findElement(By.xpath( "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[2]/div/div[2]/table/tbody/tr/td[1]/span/a/img")); waiversFile.click(); waiversFile.sendKeys(Keys.ESCAPE); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } WebElement waiversTitle = driver.findElement(By.xpath( "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[2]/div/div[2]/table/tbody/tr/td[2]/input")); waiversTitle.clear(); waiversTitle.sendKeys("Testing the Waivers folder, Opstar test"); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } WebElement issueDateWaivers = driver.findElement(By.xpath( "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[2]/div/div[2]/table/tbody/tr/td[3]/input")); issueDateWaivers.clear(); issueDateWaivers.sendKeys("01/16/2016"); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } //WebElement saveWaivers = driver.findElement(By.xpath(".//*[@id='student_folder_wrapper']/div[2]/div[2]/div/div[2]/table/tbody/tr/td[5]/span[1]/i")); //saveWaivers.click(); WebElement closeWaivers = driver.findElement( By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[2]/div/div[1]/div/a[2]")); closeWaivers.click(); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("The waivers folder has been tested"); /*************** THIS IS WHERE THE PROFESSIONAL LICENSES FOLDER STARTS ******************/ WebElement proLicensesCert = driver .findElement(By.xpath(".//*[@id='student_folder_wrapper']/div[2]/div[3]/div/div[1]/div/a[2]")); proLicensesCert.click(); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } WebElement imagePro = driver.findElement(By.xpath( "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[3]/div/div[2]/table/tbody/tr/td[1]/span/a/img")); imagePro.click(); imagePro.sendKeys(Keys.ESCAPE); WebElement proTitle = driver.findElement(By.xpath( "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[3]/div/div[2]/table/tbody/tr/td[2]/input")); proTitle.clear(); proTitle.sendKeys("OpSTAR Automation testing this title box"); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } WebElement proIssueDate = driver.findElement(By.xpath( "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[3]/div/div[2]/table/tbody/tr/td[3]/input")); proIssueDate.clear(); proIssueDate.sendKeys("05/04/2017"); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } WebElement proClose = driver.findElement( By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[3]/div/div[1]/div/a[2]")); proClose.click(); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("The professional Licenses, Certificates, Medical folder has been tested"); /*************** THIS IS WHERE THE FIRSTAID FOLDER STARTS ******************/ WebElement firstAid = driver.findElement( By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[4]/div/div[1]/div/a[2]")); firstAid.click(); try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } WebElement firstAidImage = driver.findElement(By.xpath( "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[4]/div/div[2]/table/tbody/tr/td[1]/span/a/img")); firstAidImage.click(); firstAidImage.sendKeys(Keys.ESCAPE); try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } WebElement firstAidTitle = driver.findElement(By.xpath( "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[4]/div/div[2]/table/tbody/tr/td[2]/input")); firstAidTitle.clear(); firstAidTitle.sendKeys("KeyBridge automation testing using Selenium"); try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } WebElement firstAidDate = driver.findElement(By.xpath( "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[4]/div/div[2]/table/tbody/tr/td[3]/input")); firstAidDate.clear(); firstAidDate.sendKeys("02/02/2017"); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } WebElement closeFirstAid = driver.findElement( By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[4]/div/div[1]/div/a[2]")); closeFirstAid.click(); try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("The First Aid folder has been tested"); /*************** THIS IS WHERE THE STAR FOLDER STARTS ******************/ WebElement starOpen = driver.findElement( By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[5]/div/div[1]/div/a[2]")); starOpen.click(); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } WebElement starImage1 = driver.findElement(By.xpath( "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[5]/div/div[2]/table/tbody/tr[1]/td[1]/span/a/img")); starImage1.click(); starImage1.sendKeys(Keys.ESCAPE); try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } WebElement starTitle1 = driver.findElement(By.xpath( "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[5]/div/div[2]/table/tbody/tr[1]/td[2]/input")); starTitle1.clear(); starTitle1.sendKeys("KeyBridge OpSTAR automation testing"); try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } WebElement starIssueDate1 = driver.findElement(By.xpath( "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[5]/div/div[2]/table/tbody/tr[1]/td[3]/input")); starIssueDate1.clear(); starIssueDate1.sendKeys("03/17/2017"); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } WebElement starTitle2 = driver.findElement(By.xpath( "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[5]/div/div[2]/table/tbody/tr[2]/td[2]/input")); starTitle2.clear(); starTitle2.sendKeys("CPB Automation Testing"); // WebElement starIssueDate2 = driver.findElement(By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[5]/div/div[2]/table/tbody/tr[2]/td[3]/input")); // starIssueDate2.click(); WebElement closeStarFolder = driver.findElement( By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[5]/div/div[1]/div/a[2]")); closeStarFolder.click(); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("The Star Folder has been tested"); /*************** THIS IS WHERE THE TRAINING COURSES AND TESTS FOLDER STARTS ******************/ WebElement openCourseAndTests = driver.findElement( By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[6]/div/div[1]/div/a[2]")); openCourseAndTests.click(); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } WebElement lastFive = driver.findElement( By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[6]/div/div[1]/h4/span[2]")); lastFive.click(); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } WebElement showAll = driver.findElement( By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[6]/div/div[1]/h4/span[3]")); showAll.click(); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } WebElement closeTrainingCourse = driver.findElement( By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[6]/div/div[1]/div/a[2]")); closeTrainingCourse.click(); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("The Training Courses and Tests folder has been tested"); /*************** THIS IS WHERE THE PROFESSIONAL DEVELOPMENT FOLDER STARTS ******************/ WebElement proDevelopment = driver.findElement( By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[7]/div/div[1]/div/a[2]")); proDevelopment.click(); try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } WebElement proImage = driver.findElement(By.xpath( "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[7]/div/div[2]/table/tbody/tr/td[1]/span/a/img")); proImage.click(); proImage.sendKeys(Keys.ESCAPE); try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } WebElement proTitle2 = driver.findElement(By.xpath( "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[7]/div/div[2]/table/tbody/tr/td[2]/input")); proTitle2.clear(); proTitle2.sendKeys("Testing the PRO Development box"); try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } WebElement proDevelopmentDate = driver.findElement(By.xpath( "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[7]/div/div[2]/table/tbody/tr/td[3]/input")); proDevelopmentDate.clear(); proDevelopmentDate.sendKeys("03/24/2017"); try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } WebElement closeProDevelopment = driver.findElement( By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[7]/div/div[1]/div/a[2]")); closeProDevelopment.click(); try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("The Professional Development / Individual Development Plan Folder has been tested"); /*************** THIS IS WHERE THE FLETC CERTIFICATES FOLDER STARTS ******************/ WebElement fletcOpen = driver.findElement( By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[8]/div/div[1]/div/a[2]")); fletcOpen.click(); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } WebElement fletcImage = driver.findElement(By.xpath( "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[8]/div/div[2]/table/tbody/tr/td[1]/span/a/img")); fletcImage.click(); fletcImage.sendKeys(Keys.ESCAPE); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } WebElement fletcTitle = driver.findElement(By.xpath( "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[8]/div/div[2]/table/tbody/tr/td[2]/input")); fletcTitle.clear(); fletcTitle.sendKeys("Testing the FLETC Certificates folder"); try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } WebElement fletcDate = driver.findElement(By.xpath( "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[8]/div/div[2]/table/tbody/tr/td[3]/input")); fletcDate.clear(); fletcDate.sendKeys("03/24/2017"); try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } WebElement closeFLETC = driver.findElement( By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[8]/div/div[1]/div/a[2]")); closeFLETC.click(); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("The FLETC Certificates Folder has been tested"); /*************** THIS IS WHERE THE MISCELLANEOUS CERTIFICATES FOLDER STARTS ******************/ WebElement openMisc = driver.findElement( By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[9]/div/div[1]/div/a[2]")); openMisc.click(); try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } WebElement miscImage = driver.findElement(By.xpath( "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[9]/div/div[2]/table/tbody/tr/td[1]/span/a/img")); miscImage.click(); miscImage.sendKeys(Keys.ESCAPE); try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } WebElement miscTitle = driver.findElement(By.xpath( "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[9]/div/div[2]/table/tbody/tr/td[2]/input")); miscTitle.clear(); miscTitle.sendKeys("Testing the the Misc box"); try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } WebElement miscDate = driver.findElement(By.xpath( "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[9]/div/div[2]/table/tbody/tr/td[3]/input")); miscDate.clear(); miscDate.sendKeys("12/25/2016"); try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } WebElement closeMisc = driver.findElement( By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[9]/div/div[1]/div/a[2]")); closeMisc.click(); System.out.println("The Miscellaneous folder has been tested"); System.out.println("The Training Folder automation test has successfully passed!"); }
From source file:GeneralCookieDriver.java
License:Open Source License
public WebDriver getWebDriver(Browser browser, boolean privateBrowsing) { if (browser.equals(Browser.CHROME)) { DesiredCapabilities capabilities = DesiredCapabilities.chrome(); if (privateBrowsing) { capabilities.setCapability("chrome.switches", Arrays.asList("--incognito")); }/* w w w.ja va 2 s . com*/ System.setProperty("webdriver.chrome.driver", chromeDriverLocation); return new ChromeDriver(capabilities); } else if (browser.equals(Browser.FIREFOX)) { FirefoxProfile ffp = new FirefoxProfile(); if (privateBrowsing) { ffp.setPreference("browser.privatebrowsing.dont_prompt_on_enter", true); ffp.setPreference("browser.privatebrowsing.autostart", true); } DesiredCapabilities capabilities = DesiredCapabilities.firefox(); capabilities.setCapability(FirefoxDriver.PROFILE, ffp); return new FirefoxDriver(capabilities); } else if (browser.equals(Browser.IE)) { System.setProperty("webdriver.ie.driver", ieDriverLocation); DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer(); if (privateBrowsing) { System.err.println("Launching into browsing mode is not supported in IE."); return null; } return new InternetExplorerDriver(); } else if (browser.equals(Browser.SAFARI)) { if (privateBrowsing) { System.out .println("WARNING: Selenium does not support launching into Safari private browsing mode."); System.out .println(" You will be given 10 seconds to transition into the private browsing "); System.out.println(" mode before the tests begin!"); } return new SafariDriver(); } return null; }
From source file:all_iterations_scripts.US954_Resume_Attachment.java
@Before public void setUp() throws Exception { // setting up IE, Chrome, and FireFox Web Drivers File file = new File(Constants.IE); System.setProperty("webdriver.ie.driver", file.getAbsolutePath()); File file1 = new File(Constants.Chrome); System.setProperty("webdriver.chrome.driver", file1.getAbsolutePath()); driver = new InternetExplorerDriver(); // driver=new ChromeDriver(); driver = new FirefoxDriver(); driver.manage().window().maximize(); }
From source file:at.ac.tuwien.big.testsuite.impl.selenium.BaseSeleniumTest.java
License:Apache License
protected final WebDriver createDriver() throws Exception { Exception exception = null;// w ww. j a v a2 s.c o m WebDriver webDriver = null; int tries = 0; while (tries < MAX_DRIVER_GET_RETRY) { try { if (chromeService != null) { webDriver = new RemoteWebDriver(chromeService.getUrl(), DesiredCapabilities.chrome()); } else { webDriver = new ChromeDriver(); } } catch (Exception ex) { exception = ex; try { webDriver = new FirefoxDriver(); } catch (Exception ex1) { exception.addSuppressed(ex1); try { webDriver = new SafariDriver(); } catch (Exception ex2) { exception.addSuppressed(ex2); try { if (ieService != null) { webDriver = new RemoteWebDriver(ieService.getUrl(), DesiredCapabilities.internetExplorer()); } else { webDriver = new InternetExplorerDriver(); } } catch (Exception ex3) { exception.addSuppressed(ex3); } } } } if (webDriver != null) { break; } } if (webDriver == null) { throw new RuntimeException("Could not find a browser for testing", exception); } webDrivers.add(webDriver); webDriver.get(webappUrl); if (login != null) { user = login.doLogin(webDriver); if (user == null) { user = ""; errorCollector.checkThat("Could not login", true, is(false)); } } return webDriver; }
From source file:at.ac.tuwien.big.we14.lab2.tests.SeleniumTest.java
License:Open Source License
/** * @throws java.lang.Exception/*from ww w . j a v a 2 s. com*/ */ @Before public void setUp() throws Exception { try { driver = new FirefoxDriver(); } catch (Exception ffExceptions) { try { driver = new ChromeDriver(); } catch (Exception chromeExceptions) { try { driver = new InternetExplorerDriver(); } catch (Exception ieExceptions) { throw new Exception( "Couldn't create a valid webdriver for Firefox, Chrome, or Internet Explorer"); } } } driver.get("http://" + host + ":" + port + contextPath + mainUrl); currentCheckCategory = new Stack<String>(); }
From source file:au.com.onegeek.lambda.core.BrowserFactory.java
License:Apache License
/** * Factory method that creates a OS \ architecture independent WebDriver based on the browser * requested./*from w w w . j ava 2 s . com*/ * * @param browser The name of the browser to create. Currently supports Firefox, * Chrome, IE, HTMLUnit and null. Default is HTMLunit if none * supplied. Parameter is case insensitive.. * @return The WebDriver to run the tests. * @throws Exception */ public static WebDriver getDriver(String browser) throws Exception { WebDriver driver = null; // HTMLUnit is default browser if (browser == null || browser.equalsIgnoreCase("htmlunit") || browser.trim().equalsIgnoreCase("")) { logger.debug("Creating new HTMLUnit driver"); driver = new HtmlUnitDriver(); } else if (browser.equalsIgnoreCase("firefox")) { logger.debug("Creating new Firefox driver"); driver = new FirefoxDriver(); } else if (browser.equalsIgnoreCase("opera")) { logger.debug("Creating new Opera driver"); driver = new OperaDriver(); } else if (browser.equalsIgnoreCase("chrome")) { logger.debug("Creating new Chrome driver"); // Chrome has it's own web driver implementation, need to specify the property 'webdriver.chrome.driver' Properties props = System.getProperties(); if (System.getProperty("webdriver.chrome.driver") == null) { // Create a new instance of the Chrome driver // Notice that the remainder of the code relies on the interface, // not the implementation. Enumeration e = props.propertyNames(); while (e.hasMoreElements()) { String key = (String) e.nextElement(); logger.debug("key {} -- value{}", key, props.getProperty(key)); } String os = System.getProperty("os.name"); String arch = System.getProperty("sun.arch.data.model"); String currentDir = new File(".").getAbsolutePath(); // Check OS if (os.indexOf("Mac OS X") > -1) { //capabilities.setCapability("chrome.binary", "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"); System.setProperty("webdriver.chrome.driver", currentDir + "/lib/chromedriver-macosx"); } else if (arch.equalsIgnoreCase("32") && os.indexOf("Linux") > -1) { System.setProperty("webdriver.chrome.driver", currentDir + "/lib/chromedriver-linux32"); } else if (arch.equalsIgnoreCase("64") && os.indexOf("Linux") > -1) { System.setProperty("webdriver.chrome.driver", currentDir + "/lib/chromedriver-linux64"); } else if (os.indexOf("Linux") > -1) { System.setProperty("webdriver.chrome.driver", currentDir + "/lib/chromedriver-linux32"); } else if (os.indexOf("Windows") > -1) { System.setProperty("webdriver.chrome.driver", currentDir + "/lib/chromedriver.exe"); } else { throw new Exception("Cannot find WebDriver for os, therefore cannot run these tests: " + os); } } logger.debug("Chrome driver binary: " + System.getProperty("webdriver.chrome.driver")); // driver = new ChromeDriver(capabilities); driver = new ChromeDriver(); } else if (browser.equalsIgnoreCase("ie") || browser.equalsIgnoreCase("iexplore")) { logger.debug("Creating new Internet Explorer driver"); driver = new InternetExplorerDriver(); } else { throw new BrowserNotFoundException("Browser " + browser + " not supported."); } return driver; }
From source file:automated_tests.InitialPopups.java
@Parameters("browser") @BeforeClass//from w w w . j a v a 2 s. c o m public static void beforeTest(String browser) { //set browser driver if (browser.equalsIgnoreCase("firefox")) { System.setProperty("webdriver.gecko.driver", "C:\\webDrivers\\geckodriver.exe"); driver = new FirefoxDriver(); System.out.println("Set for browser " + browser); } else if (browser.equalsIgnoreCase("chrome")) { System.setProperty("webdriver.chrome.driver", "C:\\webDrivers\\chromedriver.exe"); driver = new ChromeDriver(); System.out.println("Set for browser " + browser); } else if (browser.equalsIgnoreCase("ie")) { System.setProperty("webdriver.ie.driver", "C:\\webDrivers\\IEDriverServer.exe"); driver = new InternetExplorerDriver(); System.out.println("Set for browser " + browser); } //Opera and IE only work on Windows? // System.setProperty("webdriver.opera.driver","/Users/catherineszeto/Documents/workspace/MPN/operadriver"); // driver = new OperaDriver(); // System.setProperty("webdriver.ie.driver","/Users/catherineszeto/Documents/workspace/MPN/IEDriverServer.exe"); // driver = new InternetExplorerDriver(); else { System.out.println("Driver not configured for browser " + browser); } wait = new WebDriverWait(driver, 20); //set base URL }