List of usage examples for org.openqa.selenium WebDriver manage
Options manage();
From source file:testselenium.TestSel.java
public static String getSearchURL() throws InterruptedException { // ? String searchURL = ""; System.setProperty("webdriver.gecko.driver", "C:\\selenium\\geckodriver.exe"); WebDriver webdrAmazon = new FirefoxDriver(); webdrAmazon.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS); webdrAmazon.manage().timeouts().setScriptTimeout(30, TimeUnit.SECONDS); webdrAmazon.get("https://www.amazon.com/"); WebElement inputField = webdrAmazon.findElement(By.id("twotabsearchtextbox")); inputField.sendKeys("toys"); webdrAmazon.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS); try {/*w w w . ja v a2 s . co m*/ Thread.sleep(1000 * 6); } catch (InterruptedException e) { e.printStackTrace(); webdrAmazon.quit(); getSearchURL(); } // ? 15 ? WebElement searchBtnBlock = webdrAmazon.findElement(By.id("nav-search-submit-text")); searchBtnBlock.click(); try { Thread.sleep(1000 * 5); } catch (InterruptedException e) { e.printStackTrace(); webdrAmazon.quit(); getSearchURL(); } // ? 5 ? String currentURL = webdrAmazon.getCurrentUrl(); webdrAmazon.get(currentURL); WebElement nextPageLink = webdrAmazon.findElement(By.id("pagnNextLink")); String nextPageHREF = nextPageLink.getAttribute("href"); webdrAmazon.get(nextPageHREF); nextPageLink.click(); try { Thread.sleep(1000 * 6); } catch (InterruptedException e) { e.printStackTrace(); webdrAmazon.quit(); getSearchURL(); } // ? 5 ? currentURL = webdrAmazon.getCurrentUrl(); webdrAmazon.get(currentURL); try { Thread.sleep(1000 * 6); } catch (InterruptedException e) { e.printStackTrace(); webdrAmazon.quit(); getSearchURL(); } // ? 5 ? searchURL = webdrAmazon.getCurrentUrl(); try { Thread.sleep(1000 * 3); } catch (InterruptedException e) { e.printStackTrace(); webdrAmazon.quit(); getSearchURL(); } // ? 5 ? webdrAmazon.quit(); return searchURL; }
From source file:test_selenium.Screen_shot.java
public static void main(String[] args) throws IOException { // TODO Auto-generated method stub // Initialize WebDriver WebDriver driver; System.setProperty("webdriver.gecko.driver", "src/test_selenium/geckodriver"); driver = new FirefoxDriver(); // Wait For Page To Load driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS); // Go to URL/* w w w . j a v a2s . c o m*/ driver.get("http://localhost:8080/LogAggregatorServer/"); driver.manage().window().maximize(); driver.manage().timeouts().implicitlyWait(100, TimeUnit.SECONDS); //WebElement loginButton = driver.findElement(By.cssSelector("input.Login")); driver.findElement(By.tagName("input")).sendKeys("admin"); driver.findElement(By.cssSelector("#gwt-uid-5")).sendKeys("admin"); driver.findElement(By.cssSelector("div.v-button.v-widget")).click(); driver.manage().timeouts().implicitlyWait(1000, TimeUnit.SECONDS); driver.findElement(By.xpath("/html/body/div[1]/div/div[2]/div[2]/div/div[5]/div/div[1]/div")).click(); driver.manage().timeouts().implicitlyWait(100, TimeUnit.SECONDS); driver.findElement(By.xpath("//span[contains(text(), 'Create user')]")).click(); //driver.findElement(By.xpath("/html/body/div[1]/div/div[2]/div[2]/div/div[4]/div/div[3]/div")).click(); //edit user //driver.findElement(By.name("button")).click(); // driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); driver.findElement(By.cssSelector("#gwt-uid-9")).sendKeys("ha"); driver.findElement(By.cssSelector("#gwt-uid-11")).sendKeys("llo"); driver.findElement(By.cssSelector("#gwt-uid-13")).sendKeys("hallo@gmail.com"); driver.findElement(By.cssSelector("#gwt-uid-15")).sendKeys("hallo"); driver.findElement(By.cssSelector("#gwt-uid-17")).sendKeys("hallo"); driver.findElement(By.cssSelector("#gwt-uid-19")).sendKeys("hallo"); driver.findElement(By.xpath("/html/body/div[1]/div/div[2]/div[2]/div/div[1]/div/div[10]/div[2]/input")) .click(); driver.findElement(By.xpath("/html/body/div[2]/div[2]/div/div[2]/table/tbody/tr[1]/td/span")).click(); // administor //driver.findElement(By.xpath("/html/body/div[2]/div[2]/div/div[2]/table/tbody/tr[2]/td/span")).click(); // regular user driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS); driver.findElement(By.xpath("/html/body/div[1]/div/div[2]/div[2]/div/div[1]/div")).click(); //just click anywhere driver.findElement(By.xpath("/html/body/div[1]/div/div[2]/div[2]/div/div[1]/div/div[11]/div/div[2]/div")) .click(); driver.findElement(By.xpath("/html/body/div[1]/div/div[2]/div[2]/div/div[1]/div/div[11]/div/div[3]/div")) .click(); driver.manage().timeouts().implicitlyWait(100, TimeUnit.SECONDS); driver.findElement(By.xpath("/html/body/div[1]/div/div[2]/div[2]/div/div[4]/div/div[2]/div")).click(); //back button driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS); driver.findElement(By.xpath("//span[contains(text(), 'Logout')]")).click(); //SeleniumUtil.fluentWait(By.name("handle"), driver); //WebElement pass = driver.findElement(By.tagName("password:")); //pass.sendKeys("admin"); //pass.submit(); //WebElement button = driver.findElement(By.id("LOGIN")); //button.click(); //driver.manage().timeouts().implicitlyWait(100, TimeUnit.SECONDS); //WebDriverWait wait = new WebDriverWait(driver,30); //wait.until(ExpectedConditions.elementToBeClickable(element)); //driver.findElement(By.name("Username")).sendKeys("admin"); //driver.findElement(By.id("Next")).click(); // Enter Password //driver.findElement(By.name("Password")).sendKeys("admin"); // Wait For Page To Load //driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS); // Click on 'Sign In' button //driver.findElement(By.id("signIn")).click(); //Click on Compose Mail. //driver.findElement(By.name("Password")).submit(); //driver.findElement(By.name("Login")).click(); // Click on the image icon present in the top right navigational Bar //driver.findElement(By.xpath("//div[@class='gb_1 gb_3a gb_nc gb_e']/div/a")).click(); //Click on 'Logout' Button //driver.findElement(By.xpath("//*[@id='gb_71']")).click(); //Close the browser.*/ // Close Driver //driver.quit(); }
From source file:tooltip.ImageComparison.java
public static void setUp() throws Exception { boolean ret = true; System.out.println("Inside Setup C:\\Comcast Project Docs\\Automation\\CAAP AUTOMATION\\Selenium"); //System.setProperty("webdriver.chrome.driver","C:\\Users\\ajavva001c\\Downloads\\chromedriver.exe"); WebDriver driver = new FirefoxDriver(); driver.manage().window().maximize(); driver.get("https://activator-web-qaauto.g1.app.cloud.comcast.net/Activate/comFlow"); File url = new File("C:/Users/ajavva001c/HSD/unpacked.png"); FileInputStream fi = new FileInputStream(url); BufferedImage bufImgOne = ImageIO.read(fi); String s1 = driver.findElement(By.xpath("//*[@id='responsive']/div/div/div[2]/div/ul/li[2]/img")) .getAttribute("src"); URL urls = new URL(s1); System.out.println(urls);/* w w w .ja v a 2 s. c o m*/ BufferedImage bufImgOne1 = ImageIO.read(urls); Raster image = bufImgOne.getData(); Raster image1 = bufImgOne1.getData(); if (image.getNumBands() != image1.getNumBands() && image.getWidth() != image1.getWidth() && image.getHeight() != image1.getHeight()) { ret = false; System.out.println("fail"); } else { search: for (int i = 0; i < image.getNumBands(); ++i) { for (int x = 0; x < image.getWidth(); ++x) { for (int y = 0; y < image.getHeight(); ++y) { if (image.getSample(x, y, i) != image1.getSample(x, y, i)) { ret = false; break search; } } } } System.out.println(ret); } driver.quit(); }
From source file:UITest.Selenium2ExampleIT.java
public void testCodesCrud(DesiredCapabilities browser) { WebDriver driver = null; try {/*from w w w .ja va 2 s .co m*/ System.out.println("browser " + browser.toString()); System.out.println("connect to server @ " + SELENIUM_HUB_URL); driver = new RemoteWebDriver(new URL(SELENIUM_HUB_URL), browser); System.out.println("Driver " + driver.toString()); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); System.out.println("Is JSP enabled? " + browser.isJavascriptEnabled()); System.out.println("UI Testing being @ " + TARGET_SERVER_URL); driver.get(TARGET_SERVER_URL); System.out.println("checking for data [" + driver.getTitle() + "]"); assertEquals("Electronics, Cars, Fashion, Collectibles, Coupons and More |eBay", driver.getTitle()); } catch (MalformedURLException e) { e.printStackTrace(); assertTrue(false); } catch (Exception ex) { ex.printStackTrace(); assertTrue(false); } finally { if (driver != null) { // driver.quit(); } else { assertTrue(true); } } }
From source file:utils.WebDriverUtils.java
public static String getCookieValue(WebDriver webDriver, String name) { return webDriver.manage().getCookieNamed(name).getValue(); }
From source file:utils.WebDriverUtils.java
public static void clearCookies(WebDriver webDriver) { webDriver.manage().deleteAllCookies(); }
From source file:utils.WebDriverUtils.java
public static void addCookie(WebDriver webDriver, String name, String value, String domain, String path, Date expiry) {//from ww w . j a v a 2 s . com Cookie cookie = new Cookie(name, value, domain, path, expiry); webDriver.manage().addCookie(cookie); }
From source file:utils.WebDriverUtils.java
public static Cookie getCookie(WebDriver webDriver, String cookieName) { return webDriver.manage().getCookieNamed(cookieName); }
From source file:utils.WebDriverUtils.java
public static void deleteCookie(WebDriver webDriver, String cookieName) { webDriver.manage().deleteCookieNamed(cookieName); }
From source file:webtest.Test1.java
public void runTest1() { List<String> ouList = new ArrayList<>(); int count = 0; try {//w w w. j av a2s. c o m BufferedReader in; in = new BufferedReader( new FileReader("C:\\Users\\hallm8\\Documents\\NetBeansProjects\\WebTest\\src\\webtest\\OU")); String str; while ((str = in.readLine()) != null) { ouList.add(str); } } catch (FileNotFoundException ex) { Logger.getLogger(Test1.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(Test1.class.getName()).log(Level.SEVERE, null, ex); } FirefoxProfile fp = new FirefoxProfile( new File("C:\\Users\\hallm8\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\tiu8eb0h.default")); fp.setPreference("webdriver.load.strategy", "unstable"); WebDriver driver = new FirefoxDriver(fp); driver.manage().window().maximize(); driver.get("http://byui.brightspace.com/d2l/login?noredirect=true"); WebElement myDynamicElement = (new WebDriverWait(driver, 60)) .until(ExpectedConditions.presenceOfElementLocated(By.id("d2l_minibar_placeholder"))); // times out after 60 seconds Actions actions = new Actions(driver); for (String ouList1 : ouList) { WebDriverWait wait = new WebDriverWait(driver, 60); /** * PULLING VALENCE REQUESTS * * Step 1: Open up Selenium and authenticate by having the user sign * in. This bypasses the Authorization Protection * * Step 2: Open up HTTP Client and pass the cookies into it. * * Step 3: Open up the JSON parser of your choosing and parse into * it! */ try { Set<Cookie> seleniumCookies = driver.manage().getCookies(); CookieStore cookieStore = new BasicCookieStore(); for (Cookie seleniumCookie : seleniumCookies) { BasicClientCookie basicClientCookie = new BasicClientCookie(seleniumCookie.getName(), seleniumCookie.getValue()); basicClientCookie.setDomain(seleniumCookie.getDomain()); basicClientCookie.setExpiryDate(seleniumCookie.getExpiry()); basicClientCookie.setPath(seleniumCookie.getPath()); cookieStore.addCookie(basicClientCookie); } HttpClient httpClient = HttpClientBuilder.create().setDefaultCookieStore(cookieStore).build(); HttpGet request = new HttpGet( "https://byui.brightspace.com/d2l/api/le/1.7/" + ouList1 + "/content/toc"); request.addHeader("accept", "application/json"); HttpResponse response = httpClient.execute(request); HttpEntity entity = response.getEntity(); String jsonString = EntityUtils.toString(response.getEntity()); JSONObject obj = new JSONObject(jsonString); JSONArray modules = obj.getJSONArray("Modules"); System.out.println(jsonString); for (int i = 0; i < modules.length(); i++) { if (modules.getJSONObject(i).has("Modules")) { modules.put(modules.getJSONObject(i).getJSONArray("Modules")); } System.out.println(modules.get(i)); JSONArray topics = modules.getJSONObject(i).getJSONArray("Topics"); for (int j = 0; j < topics.length(); j++) { JSONObject topic = topics.getJSONObject(j); System.out.println(topic.get("Title")); } } JSONArray jsonArray = new JSONArray(); JSONObject jsonObject = new JSONObject(); /** * This covers Dropbox Folders * * System.out.println(ouList1); * driver.get("https://byui.brightspace.com/d2l/lms/dropbox/admin/folders_manage.d2l?ou=" * + ouList1); driver.manage().timeouts().implicitlyWait(3, * TimeUnit.SECONDS); * * List<WebElement> links = * driver.findElements(By.xpath("//a[contains(@href, * '/d2l/lms/dropbox/admin/mark/')]")); * * ArrayList<String> dropBoxes = new ArrayList<>(); * * System.out.println(links.size()); for (WebElement link : * links) { * * System.out.println(link.getAttribute("href")); if * (link.getAttribute("href") != null && * link.getAttribute("href").contains("/d2l/lms/dropbox/admin/mark/")) * { * dropBoxes.add(link.getAttribute("href").replace("mark/folder_submissions_users", * "modify/folder_newedit_properties")); * System.out.println("successfully pulled: " + * link.getAttribute("href")); } } * * for (int j = 0; j < dropBoxes.size(); j++) { String dropBox = * dropBoxes.get(j); driver.get(dropBox); * * if (!driver.findElements(By.linkText("Show Submission * Options")).isEmpty()) { driver.findElement(By.linkText("Show * Submission Options")).click(); * driver.manage().timeouts().implicitlyWait(1800, * TimeUnit.SECONDS); } * * if (driver.findElement(By.id("z_cd")).isSelected()) { * //((JavascriptExecutor) * driver).executeScript("arguments[0].scrollIntoView(true);", * driver.findElement(By.id("z_ce"))); * actions.moveToElement(driver.findElement(By.id("z_ce"))).click().perform(); * actions.moveToElement(driver.findElement(By.id("z_ci"))).click().perform(); * driver.findElement(By.id("z_c")).click(); * driver.manage().timeouts().implicitlyWait(3, * TimeUnit.SECONDS); } } * * // Response response = json.fromJson(, Response.class) /** * This covers content. */ /* driver.get("https://byui.brightspace.com/d2l/le/content/9730/Home"); driver.manage().timeouts().pageLoadTimeout(1800, TimeUnit.SECONDS); List<WebElement> dragElement = driver.findElements(By.xpath("//div[contains(@id,'TreeItem')]//div[contains(@class, 'd2l-textblock')]")); /* for (int i = 4; i < dragElement.size(); i++) { WebElement drag = dragElement.get(i); drag.click(); wait.until(ExpectedConditions.elementToBeClickable(drag)); /* driver.manage().timeouts().pageLoadTimeout(1800, TimeUnit.SECONDS); System.out.println(driver.findElement(By.xpath("//h1[contains(@class, 'd2l-page-title d2l-heading vui-heading-1')]")).getText()); (new WebDriverWait(driver, 60)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { return drag.getText().contains(d.findElement(By.xpath("//h1[contains(@class, 'd2l-page-title d2l-heading vui-heading-1')]")).getText()); } }); try { // while the following loop runs, the DOM changes - // page is refreshed, or element is removed and re-added // This took me forever to figure out!!! Thread.sleep(2000); } catch (InterruptedException ex) { Logger.getLogger(Test1.class.getName()).log(Level.SEVERE, null, ex); } List<WebElement> contentItems = driver.findElements(By.className("d2l-fuzzydate")); for (int k = 1; k < contentItems.size(); k++) { WebElement content = contentItems.get(k); wait.until(presenceOfElementLocated(By.className(content.getAttribute("class")))); WebElement parent1 = content.findElement(By.xpath("..")); System.out.println(parent1.getTagName()); WebElement parent2 = parent1.findElement(By.xpath("..")); System.out.println(parent2.getTagName()); WebElement parent3 = parent2.findElement(By.xpath("..")); System.out.println(parent3.getTagName()); WebElement parent4 = parent3.findElement(By.xpath("..")); System.out.println(parent4.getTagName()); WebElement parent5 = parent4.findElement(By.xpath("..")); System.out.println(parent5.getTagName()); WebElement parent6 = parent5.findElement(By.xpath("..")); System.out.println(parent6.getTagName()); //System.out.println(parent5.getText()); System.out.println(parent6.getAttribute("title")); } } */ /** * This covers quizzes */ /* driver.get("https://byui.brightspace.com/d2l/lms/quizzing/admin/quizzes_manage.d2l?ou=" + ouList1); driver.manage().timeouts().pageLoadTimeout(1800, TimeUnit.SECONDS); List<WebElement> links = driver.findElements(By.className("vui-outline")); ArrayList<String> quizzes = new ArrayList<>(); for (WebElement link : links) { if (link.getAttribute("href") != null && link.getAttribute("href").contains("byui.brightspace.com/d2l/lms/quizzing/admin/modify")) { quizzes.add(link.getAttribute("href")); System.out.println("successfully pulled: " + link.getAttribute("href")); } } for (int j = 0; j < quizzes.size(); j++) { String quiz = quizzes.get(j); boolean isLA = false; driver.get(quiz); driver.manage().timeouts().pageLoadTimeout(1800, TimeUnit.SECONDS); if (!driver.findElements(By.linkText("Expand optional advanced properties")).isEmpty()) { driver.findElement(By.linkText("Expand optional advanced properties")).click(); driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS); } if (driver.findElement(By.name("disableRightClick")).isSelected()) { ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", driver.findElement(By.name("disableRightClick"))); driver.findElement(By.name("disableRightClick")).click(); driver.findElement(By.id("z_b")).click(); driver.manage().timeouts().pageLoadTimeout(1800, TimeUnit.SECONDS); count++; } List<WebElement> labels = driver.findElements(By.tagName("label")); for (WebElement label : labels) { if (label.getText().contains("LA")) { isLA = true; break; } } driver.findElement(By.id("z_h_Assessment_l")).click(); driver.manage().timeouts().pageLoadTimeout(1800, TimeUnit.SECONDS); if (driver.findElement(By.name("autoExportGrades")).isSelected() && isLA == true) { driver.findElement(By.name("autoExportGrades")).click(); count++; } if (driver.findElement(By.name("autoSetGraded")).isSelected() && isLA == true) { driver.findElement(By.name("autoSetGraded")).click(); count++; } if (!driver.findElement(By.name("autoSetGraded")).isSelected() && isLA == false) { driver.findElement(By.name("autoSetGraded")).click(); count++; } if (!driver.findElement(By.name("autoExportGrades")).isSelected() && isLA == false) { driver.findElement(By.name("autoExportGrades")).click(); count++; } driver.findElement(By.id("z_b")).click(); driver.manage().timeouts().pageLoadTimeout(1800, TimeUnit.SECONDS); System.out.println("count is: " + count); /** * * Submission Views * */ /* driver.findElement(By.linkText("Submission Views")).click(); driver.manage().timeouts().pageLoadTimeout(1800, TimeUnit.SECONDS); driver.findElement(By.linkText("Default View")).click(); driver.manage().timeouts().pageLoadTimeout(1800, TimeUnit.SECONDS); if (!driver.findElement(By.name("showQuestions")).isSelected()) { System.out.println("show answers clicked!!! URL: " + quiz); driver.findElement(By.name("showQuestions")).click(); } if (!driver.findElement(By.id("z_p")).isSelected()) { driver.findElement(By.id("z_p")).click(); } if (!driver.findElement(By.name("showCorrectAnswers")).isSelected()) { driver.findElement(By.name("showCorrectAnswers")).click(); } if (!driver.findElement(By.name("showQuestionScore")).isSelected()) { driver.findElement(By.name("showQuestionScore")).click(); } if (!driver.findElement(By.name("showScore")).isSelected()) { driver.findElement(By.name("showScore")).click(); } driver.findElement(By.id("z_a")).click(); */ //} /** * This covers content. */ /* driver.get("https://byui.brightspace.com/d2l/le/content/9730/Home"); driver.manage().timeouts().pageLoadTimeout(1800, TimeUnit.SECONDS); List<WebElement> dragElement = driver.findElements(By.xpath("//div[contains(@id,'TreeItem')]//div[contains(@class, 'd2l-textblock')]")); /* for (int i = 4; i < dragElement.size(); i++) { WebElement drag = dragElement.get(i); drag.click(); wait.until(ExpectedConditions.elementToBeClickable(drag)); /* driver.manage().timeouts().pageLoadTimeout(1800, TimeUnit.SECONDS); System.out.println(driver.findElement(By.xpath("//h1[contains(@class, 'd2l-page-title d2l-heading vui-heading-1')]")).getText()); (new WebDriverWait(driver, 60)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { return drag.getText().contains(d.findElement(By.xpath("//h1[contains(@class, 'd2l-page-title d2l-heading vui-heading-1')]")).getText()); } }); try { // while the following loop runs, the DOM changes - // page is refreshed, or element is removed and re-added // This took me forever to figure out!!! Thread.sleep(2000); } catch (InterruptedException ex) { Logger.getLogger(Test1.class.getName()).log(Level.SEVERE, null, ex); } List<WebElement> contentItems = driver.findElements(By.className("d2l-fuzzydate")); for (int k = 1; k < contentItems.size(); k++) { WebElement content = contentItems.get(k); wait.until(presenceOfElementLocated(By.className(content.getAttribute("class")))); WebElement parent1 = content.findElement(By.xpath("..")); System.out.println(parent1.getTagName()); WebElement parent2 = parent1.findElement(By.xpath("..")); System.out.println(parent2.getTagName()); WebElement parent3 = parent2.findElement(By.xpath("..")); System.out.println(parent3.getTagName()); WebElement parent4 = parent3.findElement(By.xpath("..")); System.out.println(parent4.getTagName()); WebElement parent5 = parent4.findElement(By.xpath("..")); System.out.println(parent5.getTagName()); WebElement parent6 = parent5.findElement(By.xpath("..")); System.out.println(parent6.getTagName()); //System.out.println(parent5.getText()); System.out.println(parent6.getAttribute("title")); } } */ /** * This covers quizzes */ /* driver.get("https://byui.brightspace.com/d2l/lms/quizzing/admin/quizzes_manage.d2l?ou=" + ouList1); driver.manage().timeouts().pageLoadTimeout(1800, TimeUnit.SECONDS); System.out.println("Opening OU# " + ouList1); wait.until(ExpectedConditions.elementToBeClickable(By.className("d2l-tool-areas"))); List<WebElement> links = driver.findElements(By.xpath("//a[contains(@href,'/d2l/lms/quizzing/admin/modify/quiz_newedit_properties.d2l?qi=')]")); System.out.println("viu outline obtained"); ArrayList<String> quizzes = new ArrayList<>(); System.out.println(links.size()); for (WebElement link : links) { if (link.getAttribute("href") != null && link.getAttribute("href").contains("byui.brightspace.com/d2l/lms/quizzing/admin/modify")) { quizzes.add(link.getAttribute("href")); System.out.println("successfully pulled: " + link.getAttribute("href")); } } System.out.println(quizzes.size()); for (int j = 0; j < quizzes.size(); j++) { String quiz = quizzes.get(j); boolean isLA = false; driver.get(quiz); driver.manage().timeouts().pageLoadTimeout(1800, TimeUnit.SECONDS); if (!driver.findElements(By.linkText("Expand optional advanced properties")).isEmpty()) { driver.findElement(By.linkText("Expand optional advanced properties")).click(); driver.manage().timeouts().implicitlyWait(1800, TimeUnit.SECONDS); } wait.until(ExpectedConditions.elementToBeClickable(By.name("disableRightClick"))); if (driver.findElement(By.name("disableRightClick")).isSelected()) { driver.findElement(By.name("disableRightClick")).click(); driver.findElement(By.id("z_b")).click(); driver.manage().timeouts().pageLoadTimeout(1800, TimeUnit.SECONDS); count++; } List<WebElement> longAnswer = driver.findElements(By.xpath("//label[contains(.,'LA')]")); if (longAnswer.size() > 0) { isLA = true; } quiz = quiz.replace("/quiz_newedit_properties", "/quiz_newedit_assessment"); driver.get(quiz); driver.manage().timeouts().pageLoadTimeout(1800, TimeUnit.SECONDS); wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.name("autoExportGrades"))); if (driver.findElement(By.name("autoExportGrades")).isSelected() && isLA == true) { driver.findElement(By.name("autoExportGrades")).click(); count++; } wait.until(ExpectedConditions.elementToBeClickable(By.name("autoSetGraded"))); if (driver.findElement(By.name("autoSetGraded")).isSelected() && isLA == true) { driver.findElement(By.name("autoSetGraded")).click(); count++; } wait.until(ExpectedConditions.elementToBeClickable(By.name("autoSetGraded"))); if (!driver.findElement(By.name("autoSetGraded")).isSelected() && isLA == false) { driver.findElement(By.name("autoSetGraded")).click(); count++; } wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.name("autoExportGrades"))); if (!driver.findElement(By.name("autoExportGrades")).isSelected() && isLA == false) { driver.findElement(By.name("autoExportGrades")).click(); count++; } wait.until(ExpectedConditions.elementToBeClickable(By.id("z_b"))); driver.findElement(By.id("z_b")).click(); driver.manage().timeouts().pageLoadTimeout(1800, TimeUnit.SECONDS); System.out.println("count is: " + count); /** * * Submission Views * */ /* driver.findElement(By.linkText("Submission Views")).click(); driver.manage().timeouts().pageLoadTimeout(1800, TimeUnit.SECONDS); driver.findElement(By.linkText("Default View")).click(); driver.manage().timeouts().pageLoadTimeout(1800, TimeUnit.SECONDS); if (!driver.findElement(By.name("showQuestions")).isSelected()) { System.out.println("show answers clicked!!! URL: " + quiz); driver.findElement(By.name("showQuestions")).click(); } if (!driver.findElement(By.id("z_p")).isSelected()) { driver.findElement(By.id("z_p")).click(); } if (!driver.findElement(By.name("showCorrectAnswers")).isSelected()) { driver.findElement(By.name("showCorrectAnswers")).click(); } if (!driver.findElement(By.name("showQuestionScore")).isSelected()) { driver.findElement(By.name("showQuestionScore")).click(); } if (!driver.findElement(By.name("showScore")).isSelected()) { driver.findElement(By.name("showScore")).click(); } driver.findElement(By.id("z_a")).click(); */ //} /** * End of FOR LOOP stub */ } catch (IOException ex) { Logger.getLogger(Test1.class.getName()).log(Level.SEVERE, null, ex); } } }