0

I have an issue while executing a test suite. Some of the test methods are automatically executed even though they are not specified in test suite. I am using TestNG + WebDriver

Here I have two test methods:

  • verifyContentOnSignUpScreen
  • verifyLinkPresentOnFooterSection

In my test suite I have only mentioned verifyContentOnSignUpScreen but when executing the suite both test methods are executed. I am unable to find the mistake in my suite and test methods.

Test Suite:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="regressionSuite" parallel="none">

  <parameter name="ApplicationOpt" value="web"></parameter>
  <parameter name="userEmailAddress"value="xxxxx@gmail.com"></parameter>


  <test name="Test">    
    <classes>
        <!-- Sign and Login Module -->
      <class name="Tests.Login.LoginApp"/>
        <method>
            <include name="verifyContentOnSignUpScreen"></include>
            <include name="verifyLinkPresentOnFooterSection"></include> 

        </method>
    </classes>
  </test> <!-- Test -->
</suite> <!-- regressionSuite -->

Test Class:

    package Tests.Login;

    public class LoginApp extends UtilProject{

        // UI Login screen
        UILoginApp UiLoginAp = new UILoginApp();

        // Data Login module 
        TestData.Login.DataLoginApp dataLogin = new TestData.Login.DataLoginApp();

        // Action Login app
        ActionLoginApp actLogin = new ActionLoginApp();

        // Navigate Login Login App
        NavigationLoginApp naviLogin = new NavigationLoginApp();

        //Web Navigation
        NavigationWeb naviWeb = new NavigationWeb();

        //Create Instance of Extent report
        ExtentReports extentRep = extentReportGenerator(this.getClass().getName());

        //Email utility 
        emailUtility emailUti = new emailUtility();

        //Navigation Sign up 
        final static NavigationSingUp navigSignup = new NavigationSingUp();

        final static UIcustomerSignUp UisignUP = new UIcustomerSignUp();

        //Verify the content on the Sign Up screen (priority=0)
        /**
         * Verify content on Web User sign In screen
         */
        @Test
        public void verifyContentOnSignUpScreen(){
            try {
                extentRep.startTest("Verify contnet on the Login and Sign Up screen");
                wait.until(ExpectedConditions.visibilityOfElementLocated(UiLoginAp.UiEleStrtNow));
                wait.until(ExpectedConditions.visibilityOfElementLocated(UiLoginAp.UiloginScreenImgSlider));
                wait.until(ExpectedConditions.visibilityOfElementLocated(UiLoginAp.UiloginScreenCodeInput));
                wait.until(ExpectedConditions.visibilityOfElementLocated(UiLoginAp.UiloginScreenCodeButton));
                wait.until(ExpectedConditions.visibilityOfElementLocated(UiLoginAp.UiLoginScreenHeaderSection));
                wait.until(ExpectedConditions.visibilityOfElementLocated(UiLoginAp.UiLoginScreenHeaderSignUpAnSignIn));
                wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//img[@class='sliderVideo']"))).click();

                driver.switchTo().frame(driver.findElement(By.id("iframeDemoVideo")));
                wait.until(ExpectedConditions.presenceOfElementLocated(UiLoginAp.UiloginScreenMediaPlay)).click();
                driver.switchTo().defaultContent();

                wait.until(ExpectedConditions.presenceOfElementLocated(UiLoginAp.UiloginScreenMediaClose)).click();
                extentRep.log(LogStatus.PASS, "Expected content is present on sign in and sin up screen ");

            } catch (Exception e) {
                extentRep.log(LogStatus.PASS, "Conent on the Sign Up screen is not appeared correctly");
                extentRep.endTest();
                e.printStackTrace();
                Assert.fail();
            }
        }
    @Test
    public void verifyLinkPresentOnFooterSection(){
        try {
            System.out.println("verifyLinkPresentOnFooterSection");
            extentRep.startTest("Verify Privacy Policy,Terms of Service and Give Feedback link on footer section is working or not");
            wait.until(ExpectedConditions.visibilityOfElementLocated(UiLoginAp.UiLoginFooterSectonLinkPrivacyPolicy)).click();
            wait.until(ExpectedConditions.visibilityOfElementLocated(UiLoginAp.UiLoginFooterSectionPopupClose)).click();

            wait.until(ExpectedConditions.visibilityOfElementLocated(UiLoginAp.UiLoginFooterSectonLinkTermOfService)).click();
            wait.until(ExpectedConditions.visibilityOfElementLocated(UiLoginAp.UiLoginFooterSectionPopupClose)).click();

            wait.until(ExpectedConditions.visibilityOfElementLocated(UiLoginAp.UiLoginFooterSectonLinkGiveFeebBack));
            extentRep.log(LogStatus.PASS, "Verify Privacy Policy,Terms of Service and Give Feedback link on footer section is working");

        } catch (Exception e) {
            extentRep.log(LogStatus.FAIL, "Links on sign / Sign up screen is not present");
            extentRep.endTest();
            e.printStackTrace();
            Assert.fail();
        }
    }

}
  • I want something quick solution for this ..it wild be good help – Pavan T Feb 29 '16 at 16:01
1

What is the wrong here? in testng.xml file included both methods, so both are executed. below example helps you to exclude the method in class - note the tag in the second include is now an exclude.

 <test name="Test1">
 <classes>
   <class name="Tests.Login.LoginApp">
  <methods>
    <include name="verifyContentOnSignUpScreen"/>
    <exclude name="verifyLinkPresentOnFooterSection"/>
  </methods>
 </class>
 </classes>

0

Agree if we use exclude under method tag. I have another solution -

Remove "methods" tag from "class"

  • Do not include any method under with prefix "include"
  • While writing code use can use those methods which you really wanted to use

Hope this helps !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.