Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to Delete File while starting Browser session while using maven selenium plugin

pom.xml looks like

<build>    
    <plugins>
        <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>selenium-maven-plugin</artifactId>
                <version>1.0</version>
                <executions>
                    <execution>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>start-server</goal>
                        </goals>
                        <configuration>
                            <background>true</background>            
                            <logOutput>true</logOutput>                             
                            <browserSessionReuse>true</browserSessionReuse>                             
                        </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
                <!-- Skip the normal tests, we'll run them in the integration-test phase -->
                <skip>true</skip>
            </configuration>

            <executions>  
                  <execution>
                    <id>integration-tests</id>
                    <phase>integration-test</phase>
                    <goals>
                        <goal>test</goal>
                    </goals>
                    <configuration>
                        <skip>false</skip>
                    </configuration>
                </execution>  
            </executions>  
        </plugin>
    </plugins>
</build>

JUnit TestCase

@Before
public void setUp() throws Exception {

    selenium = new DefaultSelenium("localhost", 4444, "*firefox", "http://www.google.co.in/");
    selenium.start();
}

@Test
public void testUntitled() throws Exception {
    selenium.open("/");
    selenium.type("q", "Selenium Sucks");
}

@After
public void tearDown() throws Exception {
    selenium.stop();
}

I get this error message while executing goal 'mvn integration-test' I have simple testcase which opens firefox browser and search for sometext in Googe search Bar.

As of now i also have reinstalled firefox browser but it again fails .

Exception : java.lang.RuntimeException: Could not start Selenium session: Failed to start new browser session: Unable to delete file C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\customProfileDirb66b3e06cba84cc1b55eb72a418a5c61\parent.lock at com.thoughtworks.selenium.DefaultSelenium.start(DefaultSelenium.java:89) at org.argus.selenium.timepass.TestSelenium.setUp(TestSelenium.java:16)

Am i missing something in configuration or while running the mvn goal.

like image 240
Vral Avatar asked Aug 16 '26 11:08

Vral


1 Answers

Guys Funny and Weird.... just make change to pom.xml

<plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>selenium-maven-plugin</artifactId>
            <version>1.0</version>
            <executions>
                <execution>
                    <phase>pre-integration-test</phase>
                    <goals>
                        <goal>start-server</goal>
                    </goals>
                    <configuration>
                        <background>true</background>            
                        <logOutput>true</logOutput>                             
                        <browserSessionReuse>true</browserSessionReuse>                             
                    </configuration>
            </execution>
        </executions>
    </plugin>

Change the version number to 1.0.1 It should look like

<plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>selenium-maven-plugin</artifactId>
            <version>1.0.1</version>
            <executions>
                <execution>
                    <phase>pre-integration-test</phase>
                    <goals>
                        <goal>start-server</goal>
                    </goals>
                    <configuration>
                        <background>true</background>            
                        <logOutput>true</logOutput>                             
                        <browserSessionReuse>true</browserSessionReuse>                             
                    </configuration>
            </execution>
        </executions>
    </plugin>

This should work.
Thanks everyone :)

like image 147
Vral Avatar answered Aug 18 '26 01:08

Vral



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!