Running Selenium on an Alternate Port; Starting the Server from Ant
Join the DZone community and get the full member experience.
Join For Free
public void setUp() throws Exception {
// this is the normal way
// setUp(server_url, "*chrome");
// this is the alternate port way
selenium = new DefaultSelenium("localhost", 11111, "*firefox", server_url );
selenium.start();
}
Hopefully this will save a few others some time!
Free Bonus Tip
Here's how to start and stop the Selenium server from an Ant script.
<target name="start_server" description="Starts a Selenium Server in the background">
<java jar="${lib}/selenium-server.jar" fork="true" spawn="true"/>
</target>
<target name="stop_server" description="Stops your local Selenium Server">
<get taskname="selenium-shutdown"
src="http://localhost:4444/selenium-server/driver/?cmd=shutDown"
dest="result.txt"
ignoreerrors="true" />
</target>
Update
The above Ant script worked for me on Linux, but seems to not work on Windows. (sigh).
Change the arg from value= to line= and it's now working on Windows.
<java jar="${lib}/selenium-server.jar" fork="true" spawn="true" >
<arg line="-port 4444"/>
</java>
I've also found this useful.
<waitfor maxwait="30" maxwaitunit="second">
<socket server="localhost" port="${selenium.server.port}"/>
</waitfor>
Opinions expressed by DZone contributors are their own.
Trending
-
RAML vs. OAS: Which Is the Best API Specification for Your Project?
-
Send Email Using Spring Boot (SMTP Integration)
-
What to Pay Attention to as Automation Upends the Developer Experience
-
Integration Testing Tutorial: A Comprehensive Guide With Examples And Best Practices
Comments