// *** Supression des risques de banques @Test public void testSSV8VALDEBTA997IntegrationTests() throws Exception { driver.get(baseUrl + "/selectsystem-view-tomcat-oracle/login.xhtml"); Thread.sleep(1000); findElement(By.id("j_username")).clear(); findElement(By.id("j_username")).sendKeys("usercenter"); Thread.sleep(1000); findElement(By.id("j_password")).clear(); findElement(By.id("j_password")).sendKeys("pwd8888"); findElement(By.cssSelector("#login > img[alt=\"Frensh\"]")).click(); optionalClick(By.xpath("//span/a")); findElement(By.id("form:table:0:sdksds")).click(); findElement(By.xpath("(//img[@alt='English'])[11]")).click(); findElement(By.linkText("Managing Risk")).click(); new Select(findElement(By.id("globalIssuerRiskBankManagementForm:titletttrrrr"))) .selectByVisibleText("banque test 1"); Thread.sleep(1000); findElement(By.id("globalIssuerRiskBankManagementForm:hs5414")).click(); findElement(By.xpath("//td[3]/span/a/img")).click(); findElement(By.xpath("//td/div[3]/a")).click(); findElement(By.xpath("//tr[2]/td[3]/center/table/tbody/tr/td[3]/span/a/img")).click(); findElement(By.xpath("//td/div[3]/a")).click(); findElement(By.xpath("//tr[3]/td[3]/center/table/tbody/tr/td[3]/span/a/img")).click(); findElement(By.xpath("//td/div[3]/a")).click(); findElement(By.id("globalIssuerRiskBankManagementForm:hs5414")).click(); new Select(findElement(By.id("globalIssuerRiskBankManagementForm:titletttrrrr"))) .selectByVisibleText("banque test 2"); Thread.sleep(1000); findElement(By.id("globalIssuerRiskBankManagementForm:hs5414")).click(); findElement(By.xpath("//td[3]/span/a/img")).click(); findElement(By.xpath("//td/div[2]/a")).click(); findElement(By.xpath("//tr[2]/td[3]/center/table/tbody/tr/td[3]/span/a/img")).click(); findElement(By.xpath("//td/div[2]/a")).click(); findElement(By.xpath("//tr[3]/td[3]/center/table/tbody/tr/td[3]/span/a/img")).click(); findElement(By.xpath("//td/div[2]/a")).click(); findElement(By.id("globalIssuerRiskBankManagementForm:hs5414")).click(); new Select(findElement(By.id("globalIssuerRiskBankManagementForm:titletttrrrr"))) .selectByVisibleText("banque test 3"); Thread.sleep(1000); findElement(By.id("globalIssuerRiskBankManagementForm:hs5414")).click(); findElement(By.xpath("//td[3]/span/a/img")).click(); findElement(By.xpath("//td/div[3]/a")).click(); findElement(By.xpath("//tr[2]/td[3]/center/table/tbody/tr/td[3]/span/a/img")).click(); findElement(By.xpath("//td/div[3]/a")).click(); findElement(By.xpath("//tr[3]/td[3]/center/table/tbody/tr/td[3]/span/a/img")).click(); findElement(By.xpath("//td/div[3]/a")).click(); findElement(By.id("globalIssuerRiskBankManagementForm:hs5414")).click(); new Select(findElement(By.id("globalIssuerRiskBankManagementForm:titletttrrrr"))) .selectByVisibleText("banque test 2"); Thread.sleep(1000); findElement(By.id("globalIssuerRiskBankManagementForm:hs5414")).click(); findElement(By.xpath("//td[3]/span/a/img")).click(); findElement(By.xpath("//td/div[3]/a")).click(); findElement(By.xpath("//tr[2]/td[3]/center/table/tbody/tr/td[3]/span/a/img")).click(); findElement(By.xpath("//td/div[3]/a")).click(); findElement(By.xpath("//tr[3]/td[3]/center/table/tbody/tr/td[3]/span/a/img")).click(); findElement(By.xpath("//td/div[3]/a")).click(); findElement(By.id("globalIssuerRiskBankManagementForm:hs5414")).click(); findElement(By.xpath("(//img[@alt='English'])[2]")).click(); }
private boolean isAlertPresent() { try { driver.switchTo().alert(); return true; } catch (NoAlertPresentException e) { return false; } }
private boolean isElementPresent(By by) { try { driver.findElement(by); return true; } catch (NoSuchElementException e) { return false; } }
@Before public void setUp() throws Exception { driver = new FirefoxDriver(); recorder = new Recorder(); baseUrl = "http://10.0.0.107:8080/"; driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); driver.manage().window().maximize(); recorder.startRecording(this.getClass().getName()); }
@After public void tearDown() throws Exception { recorder.stopRecording(); driver.quit(); String verificationErrorString = verificationErrors.toString(); if (!"".equals(verificationErrorString)) { fail(verificationErrorString); } }
// *** l'utilisation des données "......" // ** et des données de longeurs de "nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn" // pour le champ nom // * l'impossibilité de modifier l'id d'un motif de remplacemnt une fois enregistré @Test public void testSSV8VALDEBTA008cIntegrationTests() throws Exception { driver.get(baseUrl + "/selectsystem-view-tomcat-oracle/login.xhtml"); Thread.sleep(1000); findElement(By.id("j_username")).clear(); findElement(By.id("j_username")).sendKeys("usercenter"); Thread.sleep(1000); findElement(By.id("j_password")).clear(); findElement(By.id("j_password")).sendKeys("pwd8888"); findElement(By.cssSelector("#login > img[alt=\"Frensh\"]")).click(); optionalClick(By.xpath("//span/a")); findElement(By.id("form:table:1:sdksds")).click(); findElement(By.xpath("(//img[@alt='English'])[4]")).click(); findElement(By.xpath("(//a[contains(text(),'Card Replacement Motif')])[2]")).click(); new Select(findElement(By.id("globalCardReplacementMotifForm:bank"))) .selectByVisibleText("banque test 3"); Thread.sleep(1000); findElement(By.xpath("//table[@id='globalCardReplacementMotifForm:AZ']/tbody/tr/td/a[3]/img")) .click(); Thread.sleep(1000); findElement(By.id("globalCardReplacementMotifForm:inputIdeee")).clear(); findElement(By.id("globalCardReplacementMotifForm:inputIdeee")).sendKeys(".........."); Thread.sleep(1000); findElement(By.id("globalCardReplacementMotifForm:inputLabeeee")).clear(); findElement(By.id("globalCardReplacementMotifForm:inputLabeeee")).sendKeys("ReasRp_031"); findElement(By.cssSelector("img[alt=\"save2\"]")).click(); findElement(By.id("globalCardReplacementMotifForm:fdfdfffffipppipppiiegggeooo")).click(); findElement(By.xpath("//table[@id='globalCardReplacementMotifForm:AZ']/tbody/tr/td/a[3]/img")) .click(); Thread.sleep(1000); findElement(By.id("globalCardReplacementMotifForm:inputIdeee")).clear(); findElement(By.id("globalCardReplacementMotifForm:inputIdeee")).sendKeys("ReasRp_031"); Thread.sleep(1000); findElement(By.id("globalCardReplacementMotifForm:inputLabeeee")).clear(); findElement(By.id("globalCardReplacementMotifForm:inputLabeeee")) .sendKeys("nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn"); findElement(By.cssSelector("img[alt=\"save2\"]")).click(); findElement(By.id("globalCardReplacementMotifForm:fdfdfffffipppipppiiegggeooo")).click(); findElement(By.xpath("//table[@id='globalCardReplacementMotifForm:AZ']/tbody/tr/td/a[3]/img")) .click(); Thread.sleep(1000); findElement(By.id("globalCardReplacementMotifForm:inputIdeee")).clear(); findElement(By.id("globalCardReplacementMotifForm:inputIdeee")).sendKeys("ReasRp_033"); Thread.sleep(1000); findElement(By.id("globalCardReplacementMotifForm:inputLabeeee")).clear(); findElement(By.id("globalCardReplacementMotifForm:inputLabeeee")).sendKeys("ReasRp_033"); findElement(By.cssSelector("img[alt=\"save2\"]")).click(); findElement(By.id("globalCardReplacementMotifForm:fdfdfffffipppipppiiegggeooo")).click(); findElement( By.id( "globalCardReplacementMotifForm:searchCardDesignFeesResultsId:0:scxqsjhvcqjshcvhqsceee")) .click(); findElement(By.cssSelector("img[alt=\"save2\"]")).click(); findElement(By.id("globalCardReplacementMotifForm:fdfdfffffipppipppiiegggeooo")).click(); findElement(By.xpath("(//img[@alt='English'])[2]")).click(); }
private WebElement findElement(final By locator) { (new WebDriverWait(driver, 30, 1000)) .until(ExpectedConditions.presenceOfElementLocated(locator)); (new WebDriverWait(driver, 30, 1000)) .until(ExpectedConditions.visibilityOfElementLocated(locator)); WebElement element = driver.findElement(locator); if (element.isEnabled() == false) ((JavascriptExecutor) driver).executeScript("arguments[0].disabled = false", element); return element; }
public void optionalClick(final By locator) { WebElement we = null; try { we = driver.findElement(locator); we.click(); } catch (StaleElementReferenceException ser) { } catch (NoSuchElementException nse) { } catch (Exception e) { // staticlogger.info( e.getMessage() ); } }
private String closeAlertAndGetItsText() { try { Alert alert = driver.switchTo().alert(); String alertText = alert.getText(); if (acceptNextAlert) { alert.accept(); } else { alert.dismiss(); } return alertText; } finally { acceptNextAlert = true; } }
private void test_reject_submission(WebDriver driver) { // Login CStudioSeleniumUtil.try_login( driver, CStudioSeleniumUtil.AUTHOR_USER, CStudioSeleniumUtil.AUTHOR_PASSWORD, true); // Navigate to Dashboard CStudioSeleniumUtil.navigate_to_dashboard(driver); // Edit 'index' page CStudioSeleniumUtil.edit_index_page(driver); // Switch to 'Entry' window CStudioSeleniumUtil.switch_to_window(driver, "Entry"); // Change title WebElement element = driver.findElement( By.id("accordion$pageSettings$internalTitle$input-counted$xforms-input-1")); element.clear(); element.sendKeys("Acme Home - Updated"); // Save changes CStudioSeleniumUtil.click_on(driver, By.id("formSaveButton")); // Wait for page to refresh new WebDriverWait(driver, CStudioSeleniumUtil.LONG_TIMEOUT) .until( new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { return d.getWindowHandles().size() == 1; } }); // Switch to 'Crafter Studio' window CStudioSeleniumUtil.switch_to_window(driver, "Crafter Studio"); // Check updated item CStudioSeleniumUtil.wait_until_displayed( driver, CStudioSeleniumUtil.SHORT_TIMEOUT, By.id("component-1-4-/site/website/index.xml")); CStudioSeleniumUtil.click_on(driver, By.id("component-1-4-/site/website/index.xml")); // Open confirm 'Submit to Go Live' dialog CStudioSeleniumUtil.wait_until_displayed( driver, CStudioSeleniumUtil.SHORT_TIMEOUT, By.xpath("//a[text()='Submit to Go Live']")); CStudioSeleniumUtil.click_on(driver, By.xpath("//a[text()='Submit to Go Live']")); // Confirm submission (on dialog) CStudioSeleniumUtil.wait_until_displayed( driver, CStudioSeleniumUtil.SHORT_TIMEOUT, By.id("golivesubmitButton")); CStudioSeleniumUtil.click_on(driver, By.id("golivesubmitButton")); // Close dialog CStudioSeleniumUtil.wait_until_displayed( driver, CStudioSeleniumUtil.SHORT_TIMEOUT, By.id("acnOKButton")); CStudioSeleniumUtil.click_on(driver, By.id("acnOKButton")); new WebDriverWait(driver, CStudioSeleniumUtil.SHORT_TIMEOUT) .until( new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { return d.findElement(By.tagName("body")).getText().contains("Log Out"); } }); // Log out and login as admin CStudioSeleniumUtil.logout_from_cs(driver); CStudioSeleniumUtil.try_login( driver, CStudioSeleniumUtil.ADMIN_USER, CStudioSeleniumUtil.ADMIN_PASSWORD, true); // Navigate to Dashboard CStudioSeleniumUtil.navigate_to_dashboard(driver); // Wait for In-Progress items to load CStudioSeleniumUtil.wait_until_displayed( driver, CStudioSeleniumUtil.SHORT_TIMEOUT, By.id("/site/website/index.xml")); CStudioSeleniumUtil.click_on(driver, By.id("/site/website/index.xml")); // Open 'Reject' dialog CStudioSeleniumUtil.wait_until_displayed( driver, CStudioSeleniumUtil.SHORT_TIMEOUT, By.xpath("//a[text()='Reject']")); CStudioSeleniumUtil.click_on(driver, By.xpath("//a[text()='Reject']")); // Select a reason to reject CStudioSeleniumUtil.wait_until_displayed( driver, CStudioSeleniumUtil.SHORT_TIMEOUT, By.id("rejectReasonDropDown")); Select select = new Select(driver.findElement(By.id("rejectReasonDropDown"))); select.selectByVisibleText("Not Approved"); // Send rejection CStudioSeleniumUtil.click_on(driver, By.id("golivesubmitButton")); // Close dialog CStudioSeleniumUtil.wait_until_displayed( driver, CStudioSeleniumUtil.SHORT_TIMEOUT, By.id("acnOKButton")); CStudioSeleniumUtil.click_on(driver, By.id("acnOKButton")); // As author user in separate browser (or log-out and log in), refresh dashboard CStudioSeleniumUtil.logout_from_cs(driver); CStudioSeleniumUtil.try_login( driver, CStudioSeleniumUtil.AUTHOR_USER, CStudioSeleniumUtil.AUTHOR_PASSWORD, true); // Navigate to Dashboard CStudioSeleniumUtil.navigate_to_dashboard(driver); // Check updated item CStudioSeleniumUtil.wait_until_displayed( driver, CStudioSeleniumUtil.SHORT_TIMEOUT, By.id("component-1-4-/site/website/index.xml")); CStudioSeleniumUtil.click_on(driver, By.id("component-1-4-/site/website/index.xml")); // Wait for context nav 'In Progress' menu CStudioSeleniumUtil.wait_until_displayed( driver, CStudioSeleniumUtil.SHORT_TIMEOUT, By.xpath("//div[text()=' In Progress:']")); // Close driver CStudioSeleniumUtil.exit(driver); }
private void test_image_picker(WebDriver driver) { // Check both files exist File f1 = null; File f2 = null; try { ClassLoader cl = ImagePickerTest.class.getClassLoader(); f1 = new File(cl.getResource("image_picker_1.png").toURI()); assertTrue(f1.exists()); f2 = new File(cl.getResource("image_picker_2.png").toURI()); assertTrue(f2.exists()); } catch (URISyntaxException e) { e.printStackTrace(); } assertNotNull(f1); assertNotNull(f2); // Login CStudioSeleniumUtil.try_login( driver, CStudioSeleniumUtil.AUTHOR_USER, CStudioSeleniumUtil.AUTHOR_PASSWORD, true); // Navigate to Widget CStudioSeleniumUtil.navigate_to_image_picker_widget(driver); // Upload right file size CStudioSeleniumUtil.click_on(driver, By.id("xf-4$xf-20$imageSrcAltTextTest-imageButton")); // Check popup dialog appears WebElement popup = driver.findElement(By.id("cstudio-wcm-popup-div_c")); assertTrue(popup.isDisplayed()); WebElement input = driver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/div/div/form/input")); input.sendKeys(f1.getAbsolutePath()); WebElement upload = driver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/div/div/form/input[2]")); upload.click(); new WebDriverWait(driver, CStudioSeleniumUtil.SHORT_TIMEOUT) .until( new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { WebElement e = d.findElement(By.id("xf-4$xf-20$imageSrcAltTextTest$xf-206$$a")); return e != null && e.getAttribute("class").contains("xforms-alert-inactive"); } }); WebElement mark = driver.findElement(By.id("xf-4$xf-20$imageSrcAltTextTest$xf-206$$a")); assertTrue(mark.getAttribute("class").contains("xforms-alert-inactive")); // Delete uploaded image CStudioSeleniumUtil.click_on(driver, By.id("xf-4$xf-20$imageSrcAltTextTest-deleteButton")); WebElement filename = driver.findElement(By.id("xf-4$xf-20$imageSrcAltTextTest$xf-206-filename")); assertTrue(filename.getText().equals("250W X 130H")); // Upload any image CStudioSeleniumUtil.click_on(driver, By.id("xf-4$xf-20$imageSrcTest-imageButton")); // Check popup dialog appears popup = driver.findElement(By.id("cstudio-wcm-popup-div_c")); assertTrue(popup.isDisplayed()); input = driver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/div/div/form/input")); input.sendKeys(f2.getAbsolutePath()); upload = driver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/div/div/form/input[2]")); upload.click(); new WebDriverWait(driver, CStudioSeleniumUtil.SHORT_TIMEOUT) .until( new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { WebElement e = d.findElement(By.id("xf-4$xf-20$imageSrcTest$xf-237-filename")); return e != null && e.getText().equals("/static-assets/images/image_picker_2.png"); } }); // Delete uploaded image CStudioSeleniumUtil.click_on(driver, By.id("xf-4$xf-20$imageSrcTest-deleteButton")); filename = driver.findElement(By.id("xf-4$xf-20$imageSrcTest$xf-237-filename")); assertTrue(filename.getText().equals("")); // Close driver CStudioSeleniumUtil.exit(driver); }