1

I cannot instantiate the follow class using TestNG and IE Webdriver. Can someone identify what is wrong with my source code?

public class NewQATEstClassTest {
    //For use of IE only; Please enable for IE Browser
    WebDriver driver = new InternetExplorerDriver();

        @BeforeMethod
          public void beforeMethod() {
            //Using or Launching Internet Explorer
            String exePath = "\\Users\\jj85274\\Desktop\\IEDriverServer.exe";
            //For use of IE only; Please enable for IE Browser
            System.setProperty("webdriver.ie.driver", exePath);
          }
2

I think you need to instantiate the driver after setting the path to IEDriverServer. Try:

public class NewQATEstClassTest {
//For use of IE only; Please enable for IE Browser
WebDriver driver;

    @BeforeMethod
      public void beforeMethod() {
        //Using or Launching Internet Explorer
        String exePath = "\\Users\\jj85274\\Desktop\\IEDriverServer.exe";
        //For use of IE only; Please enable for IE Browser
        System.setProperty("webdriver.ie.driver", exePath);
        driver = new InternetExplorerDriver();
      }
  • Partial fix thus far.....I seeing two windows opening now. Started InternetExplorerDriver server (32-bit) 2.53.1.0 Listening on port 11088 Only local connections are allowed Started InternetExplorerDriver server (32-bit) 2.53.1.0 Listening on port 49057 – JJ Whispers Feb 7 '17 at 18:00
  • @JJ Do you have more than @Test method in this class? That would cause any method marked as @BeforeMethod to be run more than once. If this is the case, you can change @BeforeMethod to @BeforeClass. – Rob D. Feb 7 '17 at 18:21

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.