How to open and get input from a popup before running test?



  • I want to open a popup before running my tests and after completing my test run. I want to give few inputs from the popup on basis of that my test will run.

    Suppose I have multiple links on which my project is present to test. I want to select the link from popup and then my test cases should run on that selected link.

    I have made an html file which have all fields necessary for me. I am trying to open that file in a popup before selenium start running my tests.

    Can anyone suggest how to achieve this? I am using Selenium webdriver with Testng.


  • QA Engineer

    TestNG provide a lot of annotations for thinks like that: @BeforeTest, @BeforeSuite, BeforeGroups and more: http://testng.org/doc/documentation-main.html#annotations

    It may be look like that:

    @BeforeTest
    public void setup() {
        // open your popup and click on the link
    }
    
    @Test
    public void test() {
        // test case
    }
    
    @AfterTest
    public void tearDown() {
        // close popup
    }
    

    TestNG also provide Listeners: http://testng.org/doc/documentation-main.html#testng-listeners. With Listeners you can say what before or after a test happens. Also what happens when a test finish, failed, skipped or succeed. Maybe this provide a better way for you.



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 3
  • 2
  • 2