Search code examples
javamavenseleniummaven-pluginmaven-antrun-plugin

Unable to run tests in Selenium Grid referencing Chromedriver.exe in Maven setup


As part of my project, I am bundling the whole selenium grid as part of Maven bundle. The following is how my POM looks.

<executions>
            <execution>     
                <id>default-cli</id>            
                <phase>pre-integration-test</phase>
                <goals>
                        <goal>run</goal>
                </goals>
                <configuration>
                    <target>
                        <echo message="Helloooooooooooooooooo, maven"/>
                        <java classname="org.openqa.grid.selenium.GridLauncherV3"
                              classpathref="maven.test.classpath"
                              failonerror="true"
                              fork="true">
                            <arg line="-role hub"/>
                        </java>
                        <echo message="END OF TARGET1, maven"/>
                        <java classname="org.openqa.grid.selenium.GridLauncherV3"
                              classpathref="maven.test.classpath"
                              failonerror="true"
                              fork="true">
                            <arg line="-role node
                                       -hub http://localhost:4444/grid/register 
                                       -port 5555"/>
                        </java>
                        <echo message="END OF TARGET2, maven"/>
                    </target>
                </configuration>

                </execution>
            </executions>

So, what I am planning to do is execute mvn antrun:run. This will be followed by mvn test which runs all the Selenium tests. The issue I am facing here is when I run the maven antrun:run command, seleniun grid with hub and node launches. But I also wish to invoke Chromedriver.exe as all my tests are based in ChromeDriver.

Is there something which we can do to mimic the following

java -Dwebdriver.chrome.driver=C:\Selenium\chromedriver.exe -jar %~dp0\selenium-server-standalone.jar -role hub in POM. As of now, I believe only -role hub is passed to the server jar and due to which I am not able to run any of the Selenium tests.


Solution

  • Well. I am using webdrivermanager to solve the above issue. Very sleek and easy to implement.