Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Check if warning message will display if email is valid.///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- @Test(priority = 2, dataProvider = "ValidEmailList", dataProviderClass = ValidEmailTestCase.class)//, enabled = false)
- public void ValidEmailValidation(String email) throws InterruptedException
- {
- driver.switchTo().defaultContent();
- driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
- Thread.sleep(1000);
- driver.switchTo().frame(2);
- Log.info("Test Case: emailValidation. Input: "+ email);
- Log.info("Input email into text field: "+ email);
- WebDriverWait wait2 = new WebDriverWait(driver, 60);
- wait2.until(ExpectedConditions.visibilityOf(driver.findElement(By.xpath("//*[@id=\"mc-EMAIL\"]"))));
- driver.findElement(By.xpath("//*[@id=\"mc-EMAIL\"]")).sendKeys(email);
- Thread.sleep(500);
- Log.info("Click on subscribe button for email: "+ email);
- // Subscribe button
- detectElementThenClick("Subscribe button","//*[@id=\"SignupForm_0\"]/div[2]/form/div[2]/input");
- driver.findElement(By.xpath("//*[@id=\"mc-EMAIL\"]")).clear();
- Thread.sleep(4000);
- // warning message
- String warningMessage = driver.findElement(By.xpath("//*[@id=\"uniqName_3_0\"]/div")).getText();
- Log.info("Warning Message: " + warningMessage);
- if(warningMessage.contains("This field is required.")
- || warningMessage.contains("Please enter a valid email address.")
- || warningMessage.contains("The username portion of the email address is invalid")
- || warningMessage.contains("The domain portion of the email address is invalid"))
- {
- InitialSetup.softAssert.assertTrue(false);
- InitialSetup.softAssert.assertAll();
- }
- else if(driver.findElement(By.xpath("//*[@id=\"SignupForm_0\"]/div[1]/div/span/span")).getText().equals("Thank you for subscribing!"))
- {
- Log.info("Valid Email.");
- Assert.assertTrue(true);
- }
- Log.info("-----------------------------------------------------");
- driver.switchTo().defaultContent();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement