I wrote a Ghostdriver Maven Java project where I call many instances of the jar file using a shell script in Ubuntu 14.04 64bit.
Each line in my shell script calls a new instance of my jar file.
The format of each line:
screen -dmS name java -jar /path/name.jar arg1 arg2 arg3
Currently I have 1 network interface (eth0) split up into multiple network aliases (eth0:1, eth0:2, etc), each alias points to a private IP which in turns points to a public IP.
I am trying to find the best way to allocate a private IP and possibly port number to each instance of my java program. Currently I call Ghostdriver inside my program.
The way I call ghost driver within my program:
public class className {
PhantomJSDriver driver;
public static final File PHANTOMJS_EXE = new File("//home/username/phantomjs/bin/phantomjs");
public className() {
callGhostdriver();
driver.quit();
}
private void callGhostdriver() {
{
DesiredCapabilities caps = new DesiredCapabilities();
caps.setJavascriptEnabled(true);
caps.setCapability("phantomjs.binary.path",
PHANTOMJS_EXE.getAbsolutePath());
driver = new PhantomJSDriver(caps);
driver.manage().window().maximize();
actions = new Actions(driver);
}
}
}
Any help would be greatly appreciated.
***Update****
I tried changing the callGhostdriver method but had no success.
private void callGhostdriver() {
DesiredCapabilities dcaps = new DesiredCapabilities();
dcaps.setCapability(
PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,
PHANTOMJS_EXE.getAbsolutePath());
String[] phantomJsArgs = {"--webdriver=172.16.190.131:6781"};
dcaps.setCapability(
PhantomJSDriverService.PHANTOMJS_CLI_ARGS,
phantomJsArgs);
driver = new PhantomJSDriver(dcaps);
driver.manage().window().maximize();
actions = new Actions(driver);
}
Argument --webdriver=IP:PORT seems to be overridden by a default --webdriver call.
Output from running jar:
*Apr 12, 2015 5:26:25 PM org.openqa.selenium.phantomjs.PhantomJSDriverService INFO: port: 8651 Apr 12, 2015 5:26:25 PM org.openqa.selenium.phantomjs.PhantomJSDriverService INFO: arguments: [--webdriver=172.16.190.131:6781, --webdriver=8651, --webdriver-logfile=/home/RemovedPath/phantomjsdriver.log] Apr 12, 2015 5:26:25 PM org.openqa.selenium.phantomjs.PhantomJSDriverService INFO: environment: {} [INFO - 2015-04-12T21:26:26.584Z] GhostDriver - Main - running on port 8651
Port 6781 with the different private IP should be what it is using but it uses 8651 instead.