Selenium opening two browsers even I instantiating only one

Asked

Viewed 577 times

1

Galley,

I am using Cucumber with Selenium in JAVA. I have the following problem: every step I do:

private WebDriver driver;
@Before
public void before(){
   driver = new FirefoxDriver();
}

@Given("^something$)
public void someGivenMehtod(){...}
@When("^anotherThing$)
public void someWhenMethod(){...}
@Then("^conclusion$)
public void someThenMethod(){...}

@After
public void after(){
   driver.close();
}

However, I have 4 Steps. Every step opens TWO (2) instances of Firefox.

Could you tell me why this happens?

Grateful.

My environment: Java 8, Firefox 47.0.1 plus Maven:

<!-- SELENIUM -->
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>2.53.1</version>
        </dependency>

        <!-- SELENIUM: Fifefox WebDriver -->
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-firefox-driver</artifactId>
            <version>2.53.1</version>
        </dependency>

        <!-- SELENIUM: Chrome WebDriver -->
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-chrome-driver</artifactId>
            <version>2.53.1</version>
        </dependency>

        <!-- CUCUMBER -->

        <!-- CUCUMBER: Java -->

        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>1.2.4</version>
            <scope>test</scope>
        </dependency>

        <!-- CUCUMBER: Core -->
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-core</artifactId>
            <version>1.2.4</version>
        </dependency>

        <!-- CUCUMBER: JUnit -->
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>1.2.4</version>
        </dependency>

        <!-- CUCUMBER: JVM Deps -->
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-jvm-deps</artifactId>
            <version>1.0.5</version>
        </dependency>

        <!-- CUCUMBER: Reports -->
        <dependency>
            <groupId>net.masterthought</groupId>
            <artifactId>cucumber-reporting</artifactId>
            <version>2.5.0</version>
        </dependency>

        <!-- CUCUMBER: Gherkin -->
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>gherkin</artifactId>
            <version>2.12.2</version>
        </dependency>

        <!-- MOCKITO: All -->
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
            <version>1.10.19</version>
        </dependency>

        <!-- GOOGLE COBERTURA -->
        <dependency>
            <groupId>com.google.code.maven-play-plugin.net.sourceforge.cobertura</groupId>
            <artifactId>cobertura</artifactId>
            <version>1.9.2-patched-play-cobertura-1.0-jdk15</version>
        </dependency>

        <!-- SELENIUM: Firefox WebDriver -->
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-firefox-driver</artifactId>
            <version>2.53.1</version>
        </dependency>

        <!-- SELENIUM: Chrome WebDriver -->
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-chrome-driver</artifactId>
            <version>2.53.1</version>
        </dependency>

        <!-- JUnit -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>
  • @Given("^something$) - Isn’t one missing " here?

  • It is. But that’s just an example. It’s not really like that. The phrase is different, but it doesn’t interfere.

  • I think you’ll need more details about your code so someone can help you. Take a look at this: [mcve]

  • Already managed to tidy up? post more details

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.