How to start selenium standalone server ith IE11 webdriver? - selenium

I'm trying this command in order to start selenium standalone server with internet explorer 11:
java -jar selenium-server-standalone-3.141.59.jar -Dwebdriver.ie.driver=C:\Users\MyUser\Downloads\IEDriverServer_x64_3.14.0\IEDriverServer.exe -Dwebdriver.ie="C:\Program Files\internet explorer\iexplore.exe"
where MyUser is my current username.
But I'm getting exception.
Using selenium standalone server version 2.53.1 works fine with the same arguments but it's recommanded to use the same version for IE webdriver and selenium.
Here's the exception I have:
Exception in thread "main" com.beust.jcommander.ParameterException: Was passed main parameter '-Dwebdriver.ie.driver=C:\Users\Xavier\Downloads\IEDriverServer_x64_3.14.0\IEDriverServer.exe' but no main parameter was defined in your arg class
at com.beust.jcommander.JCommander.initMainParameterValue(JCommander.java:936)
at com.beust.jcommander.JCommander.parseValues(JCommander.java:752)
[...]
Does anyone know how to run it ?

Fixed this by moving -jar .... at the end of the command:
java -Dwebdriver.ie.driver=C:\Users\MyUser\Downloads\IEDriverServer_x64_3.14.0\IEDriverServer.exe -Dwebdriver.ie="C:\Program Files\internet explorer\iexplore.exe" -jar selenium-server-standalone-3.141.59.jar

Related

Why do we need org.openqa.grid.selenium.GridLauncherV3 in selenium grid

Is there any specific reason why we use GridlauncherV3, Currently doing a project where I use custom servlets for executing some task
For launching node:
java -Dwebdriver.chrome.driver=chromedriver -cp testservlet.jar:selenium-server-standalone.jar org.openqa.grid.selenium.GridLauncherV3 -role node -maxSession 10 -port 4444 -host localhost -hub http://localhost:4444/grid/register -browser browserName=chrome,version=103,platform=LINUX,maxInstances=10 -servlets testservlet.copies.DemoServlet,testservlet.copies.Demo2Servlet
Couldn't find any reason but if removed it throws an error, Were it needs a params
Unrecognized option: -role
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Thanks in advance.
As you are using are using java -cp, it is a requirement to specify the class that contains the main() method.
In the case of creating a jvm to run as selenium grid, you require the class that contains the main() method, in this case that is org.openqa.grid.selenium.GridLauncherV3.
This method is used to initiate the grid with all the required configuration in your cli command.
See the method here: GridLauncherV3

How to run test on specific browser by selenium grid

I have register two platform with chrome browser on windows 7 and windows 10 into selenium grid server.
I want to run a test at Chrome browser on Windows 10 but when i run the test, the test randomly run on Windows 7 and randomly run on Windows 10 on chrome.
Do you have an idea how to do the configuration to run the test on specific browser and platform when we have registered multiple platform?
hub:
java -jar selenium-server-standalone-3.7.1.jar -role hub
register node on windows 7:
java -Dwebdriver.chrome.driver=chromedriver_2.33.exe -jar selenium-server-standalone-3.7.1.jar -role node -hub http://localhost:4444
register node on windows 10:
java -Dwebdriver.chrome.driver=chromedriver_2.33.exe -jar selenium-server-standalone-3.7.1.jar -role node -hub http://localhost:4444
protractor.conf.js
exports.config = {
specs: [
'**/*.mytest.e2e-spec.ts'
],
multiCapabilities: [
{
browserName: 'chrome',
platform: 'WIN10',
}
],
seleniumAddress: 'http://localhost:4444/wd/hub',
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
print: function () {
}
},
onPrepare: function () {
require('ts-node').register({
project: 'e2e/tsconfig.e2e.json'
});
}
};
Selenium Grid Installation Process:-
Download Selenium server standalone jar file in which you want to
create Hub
Create a new java project and add it to build path
Start the Hub Using Below Command in your machine:-
java -jar selenium-server-standalone-3.9.1.jar –role hub -port 4446
Open ip address/grid/console in host browser "or" localhost: portnumber/grid/console
Start the Node Using Below Command in another machine:
Download Selenium server standalone jar file in another laptop
it is not necessary that node contains eclipse. But Java Should be installed.
go to file path where selenium standalone is kept
Type Below command
java -jar selenium-server-standalone-3.9.1.jar –role webdriver –hub ipaddress/grid/
register –port 5566
(but Here your test will fail because here file path for chrome Driver or gecko driver is not provided in the hub.)
java –Dwebdriver.chrome.driver="provide path for chrome driver" -jar selenium-server-standalone-3.9.1.jar –role webdriver –hub ipaddress/grid/register –port 5566
I would suggest that you do the following
Create a node configuration file as seen here, wherein for the WINDOWS7 node, you specify the appropriate platform (make sure you pick a value from here)
Now you start off the node by specifying this newly created nodeConfig json using the command line parameter -nodeConfig node.json ( For more details refer to my blog post here )
Now based on the PLATFORM capabilities specified by your test, it would be routed to the appropriate node.
You need to tweak the commands for registering the nodes as follows :
Register node on Windows 7:
java -Dwebdriver.chrome.driver=chromedriver_2.33.exe -jar selenium-server-standalone-3.7.1.jar -role node -hub http://localhost:4444/grid/register
Register node on Windows 10:
java -Dwebdriver.chrome.driver=chromedriver_2.33.exe -jar selenium-server-standalone-3.7.1.jar -role node -hub http://localhost:4444/grid/register
As per your question and DebanjanB answer, You have two nodes and two hubs. You need to register the nodes with same hub. Please try with following configuration, it may works.
Start your hub on windows 7 Machine with following command,
java -jar selenium-server-standalone-3.7.1.jar -role hub
Start/register your first node on windows 7 with following command,
java -Dwebdriver.chrome.driver=chromedriver_2.33.exe -jar selenium-server-standalone-3.7.1.jar -role node
start/register your second node on windows 10 with following command,
java -Dwebdriver.chrome.driver=chromedriver_2.33.exe -jar selenium-server-standalone-3.7.1.jar -role node -hub http://"IP Address OF Windows 7 machine":4444/grid/register
To verify the nodes are listed on hub, just open the url http://localhost:4444/grid/console on windows 7 machine. Then, verify your nodes are listed on the page.
You have to run your script from the windows 7 machine because your selenium address is using localhost address( seleniumAddress: 'http://localhost:4444/wd/hub'). if you want to run from windows 10 machine or any other machine. change the selenium address as 'http://"windows7ipaddress":4444/wd/hub' in config file.
I have tested it on my machine it is working fine. It will start the chrome on windows 10 machine as your multiCapabilities platform value is WIN10.
note: replace the value of ip address value in place where ever required.

Unable to define maxInstances when launching hub via Selenium 3.0.0 beta3

I've been using the selenium-server-standalone-2.53.0.jar and recently tried to upgrade to version 3.0.0-beta3.
I'm attempting to spin-up a hub using the maxInstances parameter with the following command:
java -jar %~dp0DriverRepo\selenium-server-standalone-3.0.0-beta3.jar -role hub -port 5555 -maxInstances 9
This was working in 2.53.0, but in 3.0.0-beta3 I'm met with the following exception:
Exception in thread "main" com.beust.jcommander.ParameterException: Unknown option: -maxInstances
at com.beust.jcommander.JCommander.parseValues(JCommander.java:742)
at com.beust.jcommander.JCommander.parse(JCommander.java:282)
at com.beust.jcommander.JCommander.parse(JCommander.java:265)
at com.beust.jcommander.JCommander.<init>(JCommander.java:210)
at org.openqa.grid.selenium.GridLauncherV3$2.setConfiguration(GridLauncherV3.java:224)
at org.openqa.grid.selenium.GridLauncherV3.buildLauncher(GridLauncherV3.java:138)
at org.openqa.grid.selenium.GridLauncherV3.main(GridLauncherV3.java:67)
Apparently maxInstances is no longer a valid argument. I've searched for documentation regarding any changes that may have been made for use of the maxInstances parameter but I've had no luck. Has anyone else run into this issue, or is anyone aware of the proper way to spin-up a hub in 3.0.0-beta3 in a comparable way?
I don't remember ever using an argument called maxInstances. I think that earlier there was no validation for invalid command line arguments but with Selenium 3, they perhaps enabled it.
Here's an example of why I feel my theory is true
Selenium 2.53.1 output wherein I am providing an invalid argument named krishnan
selenium-server -role hub -krishnan 100
22:28:37.762 INFO - Launching Selenium Grid hub
2016-09-26 22:28:38.366:INFO::main: Logging initialized #758ms
22:28:38.378 INFO - Will listen on 4444
22:28:38.421 INFO - Will listen on 4444
2016-09-26 22:28:38.424:INFO:osjs.Server:main: jetty-9.2.z-SNAPSHOT
2016-09-26 22:28:38.452:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletContextHandler#32eebfca{/,null,AVAILABLE}
2016-09-26 22:28:38.479:INFO:osjs.ServerConnector:main: Started ServerConnector#6ec8211c{HTTP/1.1}{0.0.0.0:4444}
And here's how Selenium 3 beta version behaves for the same command line.
java -jar selenium-server-standalone-3.0.0-beta2.jar -role hub -krishnan 100
Exception in thread "main" com.beust.jcommander.ParameterException: Unknown option: -krishnan
at com.beust.jcommander.JCommander.parseValues(JCommander.java:742)
at com.beust.jcommander.JCommander.parse(JCommander.java:282)
at com.beust.jcommander.JCommander.parse(JCommander.java:265)
at com.beust.jcommander.JCommander.<init>(JCommander.java:210)
at org.openqa.grid.selenium.GridLauncherV3$2.setConfiguration(GridLauncherV3.java:216)
at org.openqa.grid.selenium.GridLauncherV3.buildLauncher(GridLauncherV3.java:130)
at org.openqa.grid.selenium.GridLauncherV3.main(GridLauncherV3.java:67)
Selenium has never had any argument named maxInstances. It only had something called maxSession`.
The only usage for maxInstances has been within a node configuration file as shown here which is passed to a Selenium node via the -nodeConfig argument. This represents the number of concurrent browser instances per browser flavor that can be opened up in a node.

Selenium Grid with safari browser

Plese Help me
How do I instantiate the Safari in selenium grid
capabilities = new DesiredCapabilities();
// Version browser
capabilities.setVersion(versaoBrowser);
capabilities.setBrowserName("safari");
capabilities.setJavascriptEnabled(true);
// Platform test runner
capabilities.setPlatform(platform);
On the server is weel
-browser "browserName=safari,version=5,platform=WINDOWS,javascriptEnable=true"
If the question is about using Safari the new way, with SafariDriver over Grid2, then this would be the typical method I believe (more or less):
import org.openqa.selenium.*;
import org.openqa.selenium.remote.*;
import java.net.*;
DesiredCapabilities c = new DesiredCapabilities();
c.setBrowserName("safari");
/* you can then set version & platform as well, but the minimum is just browser. Maybe for Grid2 you need the others, but for remote web driver only, you don't.
*/
WebDriver d = new RemoteWebDriver(new URL("http://hubIpOrHostname:hubPort/wd/hub"),c);
and that should work. On the server side, I believe you just instantiate normally for Grid2 per the wiki docs (last I check, could be diff now):
//start hub
java -jar selenium-server-standalone-2.21.0.jar -role hub -port theHubPort
//start the node
java -jar selenium-server-standalone-2.21.0.jar -role node -hub http:
//172.22.6.198:4446/wd/hub -port theNodePort
however, seems that the current Grid2 doesn't offer Safari support. When I looked up the console for the registered node in hub, it didn't show icon for Safari. Maybe I missed something. I'll try adding platform and version next time to see if that makes a diff but think not.
Here's a snippet of the error I get for Grid2 with SafariDriver:
May 11, 2012 6:01:11 PM org.openqa.selenium.remote.RemoteWebDriver execute
INFO: Executing: [null, newSession {"desiredCapabilities":"Capabilities [{browse
rName=safari}]"}]
// Error: // Uncaught Exception: Typed variable declaration : Object constructor
: at Line: 7 : in file: : new RemoteWebDriver ( new URL ( "http:
//172.22.6.198:4446/wd/hub" ) , c )
Target exception: org.openqa.selenium.WebDriverException: Error forwarding the n
ew session cannot find : {browserName=safari}
Command duration or timeout: 109 milliseconds
To note: with webdriver, same code can be used for (standalone) remote webdriver execution vs grid, difference is that for remote you use remote server ip and with grid2, you use hub ip. SafariDriver works over remote webdriver, but currently doesn't seem to work over Grid2 yet.
remote webdriver startup:
java -jar selenum-server-standalone-2.21.0.jar [-port somePort]
//default port of 4444
I believe what you are asking for is something like this?
selenium = new DefaultSelenium("localhost", 4444, *safari,"http://google.com.au");
selenium.start();
I generally use WebDriver, but my understanding is capabilities are options for when you create an instance of a browser, not to open the browser itself. Though I could be wrong as I am not experienced with Selenium Grid.
EDIT: This and this might help.

Selenium grid newbie questions

Ok, I have already several testcases written for Webdriver approach. But now I need get the Selenium Grid for possible stress testing of the webapp.
I found this demo but its unable to control the Firefox 11. Then I found out this wiki page which is two level higher than I can understand, but that JAR File is supposedly able to control the Firefox 11.
What I need - some resources how to get the Grid started and how to let it do simple test - like writing "Hello World" into Google search bar and then clicking "Search."
EDIT
This is the error when I am trying to run the grid as node
D:\_dev\selenium-grid-1.0.8\lib>java -jar selenium-server-standalone-2.20.0.jar -role node -hub http://localhost:4444/grid/register
22-Mar-2012 10:33:48 org.openqa.grid.selenium.GridLauncher main
INFO: Launching a selenium grid node
Exception in thread "main" java.lang.NoSuchMethodError: java.lang.String.isEmpty()Z
at org.openqa.grid.common.RegistrationRequest.getRemoteControlConfiguration(RegistrationRequest.java:585)
at org.openqa.grid.internal.utils.SelfRegisteringRemote.startRemoteServer(SelfRegisteringRemote.java:86)
at org.openqa.grid.selenium.GridLauncher.main(GridLauncher.java:72)
And this is output from server which seems ok
D:\_dev\selenium-grid-1.0.8\lib>java -jar selenium-server-standalone-2.20.0.jar -role hub
22-Mar-2012 10:33:33 org.openqa.grid.selenium.GridLauncher main
INFO: Launching a selenium grid server
360 [main] INFO org.seleniumhq.jetty7.server.Server - jetty-7.x.y-SNAPSHOT
422 [main] INFO org.seleniumhq.jetty7.server.handler.ContextHandler - started o.s.j.s.ServletContextHandler{/,null}
438 [main] INFO org.seleniumhq.jetty7.server.AbstractConnector - Started SocketConnector#0.0.0.0:4444
If you are working with windows, you need to add the path to firefox to your PATH environment variable. The reason for this is, that windows then knows what program to start, when you call firefox from command line, for example.
Then you need to donwload the selenium server standalone and then start the hub
java -jar selenium-server-standalone-2.20.0.jar -role hub
and also the client:
java -jar selenium-server-standalone-2.20.0.jar -role node -hub http://localhost:4444/grid/register
Now you need to create a new Java Project in Eclipse, for example like so:
class MyFristTest{
//using the #test annotation tells eclipse
//to use junit (or tells you to import it)
#Test
public void myTest(){
Selenium selenium = new DefaultSelenium(“localhost”, 4444, “*firefox”, “http://www.google.com”);
DesiredCapabilities capability = DesiredCapabilities.firefox();
WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capability);
driver.get("http://www.example.com");
driver.findElement(By.linkText("RFC 2606")).click();
driver.findElement(By.linkText("txt")).click();
}
If you now start the JUnit Test, it should magically work.