RE: Inheritance in Selenium not showing correct test count

I tried to test my inheritance skill with Selenium. After creating package called MailAccess I have 3 classes under MailAccess package-

  1. VisitPage class (main)
  2. VerifyTitle class (extends VisitPage)
  3. VerifyUsername class (extends VerifyTitle)

    public class VisitPage { public static FirefoxDriver f= new FirefoxDriver();

            @Test
        public void testURL() {
            f.get("https://www.mail.com");
        }
    
    
    public class VerifyTitle extends VisitPage {
    
        @Test
        public void testTitle(){
    
            super.testURL();
            String title=f.getTitle();
            Assert.assertTrue(title.contains("email"));
            System.out.print(title);
        }
    }
    
    public class VerifyUsername extends VerifyTitle {
    
        @Test
        public void testUserName(){
    
            super.testTitle();
            f.findElement(By.id("login-button")).click();
            f.findElement(By.id("login-email")).sendKeys("jnuit11%mail.com");
    
            //code below to get sendKeys value
            WebElement w= f.findElement(By.id("login-email"));
            String emailID= w.getAttribute("value");
            System.out.println("Email id used " + emailID);
    
            if(!(emailID).contains("@")){
                System.out.println("Invalid character");
            }
        }
    }
    

Problem: When I run it (right click on Package name>Run as> TestNG Test), this is what I see

Free email accounts | Register today at mail.comEmail id used jnuit11%mail.com
Invalid character
PASSED: testUserName
PASSED: testURL
PASSED: testURL
PASSED: testURL

===============================================
    Default test
    Tests run: 4, Failures: 0, Skips: 0

Question: Why 4 tests when I have only 3 and 3 have same name as testURL?

nishu81 Default Asked on May 14, 2016 in Selenium WebDriver.
Add Comment
2 Answers

Nishu,

That looks like a very interesting problem. Let me try this at home and I will get back to you.

Virender

Professor Answered on May 16, 2016.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.