Grid2 with saunter

130 views
Skip to first unread message

thirumal rao

unread,
Jun 30, 2013, 11:46:33 AM6/30/13
to sau...@googlegroups.com
Was trying to use selenium grid with saunter and am encountering issues. 

Here are the steps I followed.

1. Started the hub with the command
java -jar /Users/Thirumal/workspace/selenium-server-standalone-2.32.0.jar -role hub -maxInstances=5

2. Started 2 nodes - 
java -jar /Users/Thirumal/workspace/selenium-server-standalone-2.32.0.jar -role node -hub http://localhost:4444/grid/register -port 5555

java -jar /Users/Thirumal/workspace/selenium-server-standalone-2.32.0.jar -role node -hub http://localhost:4444/grid/register -port 5556

3. Tried running the tests with the command - pysaunter -s -m TestMacProvisioningProfiles -n 1

Result:
It prints scheduling tests via LoadScheduling on the console, does not launch the browser, and after some time it just prints EEEE for 4 scripts which was supposed to run. I had given the port number as 4444 in the saunter.ini file.

However, it works fine if I change port number in saunter.ini file to 5555 (node1). Does this mean I have to give the port number of node against which we have to run the tests ? It did not make sense to me. 
Am I missing something here ? 



--
"Peace cannot be kept by force. It can only be achieved by understanding."

http://www.raoathisbest.blogspot.com

Adam Goucher

unread,
Jun 30, 2013, 12:19:10 PM6/30/13
to sau...@googlegroups.com
Just stopping through for a second, but have you seen http://element34.ca/blog/py-saunter-0-48-selenium-grid-parallel-execution-and-ci ?
--
You received this message because you are subscribed to the Google Groups "Saunter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to saunter+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

thirumal rao

unread,
Jun 30, 2013, 12:22:00 PM6/30/13
to sau...@googlegroups.com
yes, I did. 

thirumal rao

unread,
Jul 1, 2013, 12:09:00 AM7/1/13
to sau...@googlegroups.com
When I start the hub (on port 4444) and node (port 5555) with the saunter.ini file having port number 4444, saunter is not launching the browser. However, it works when I change the port number in config file to 5555(node port).
Is this an expected behaviour ? 

- Thirumal

Adam Goucher

unread,
Jul 1, 2013, 9:37:44 AM7/1/13
to sau...@googlegroups.com
If you write a quick script that doesn't use saunter and point it at the hub, does it work as expected?

-adam

Adam Goucher

unread,
Jul 1, 2013, 10:05:11 AM7/1/13
to sau...@googlegroups.com
While at a client last week we noticed that if something has an import
exception then it will hide the actual exception and give you a
less-than-useful one around screenshotting.

In conftest.py, if you replace the existing pytest_runtest_call function
with this one you will get the true error

def pytest_runtest_call(item, __multicall__):
try:
__multicall__.execute()
except Exception as e:
if hasattr(item.parent.obj, 'driver') or
hasattr(item.parent.obj, 'selenium'):
try:
item.parent.obj.take_named_screenshot('exception')
except:
raise e
raise

The second layer of try/except is what was added. And yes, it likely
shouldn't be a naked except...

-adam

thirumal rao

unread,
Jul 2, 2013, 5:27:02 AM7/2/13
to sau...@googlegroups.com
Nope. I am using selenium 2.33(tried with 2.32 too)... looks like hub is not able to communicate with the node.

I just ran the following commands each in a different terminal window- 

java -jar /Users/Thirumal/workspace/selenium-server-standalone-2.33.0.jar -role hub
java -jar /Users/Thirumal/workspace/selenium-server-standalone-2.32.0.jar -role webdriver -hub http://localhost:4444/grid/register -port 5556

Wrote a simple script and executed it - 

from selenium import webdriver

driver = webdriver.Remote("http://localhost:4444/wd/hub", webdriver.DesiredCapabilities.FIREFOX)

driver.get('http://www.google.com')

driver.find_element_by_id('gbqfq').send_keys('thiru')

driver.quit()


This script executes when the server is started as standalone, but does not work when server is started as a hub


When I check the grid console (http://localhost:4444/grid/console) prior to execution, I see this message - 'DefaultRemoteProxy unknown version,Connection to http://17.149.237.222:5540 refused
id : http://17.149.237.222:5540, OS : mixed OS'

In the terminal however, I see the hub displaying the node as available -

Jul 2, 2013 2:50:33 PM org.openqa.grid.internal.ProxySet getNewSession
INFO: Available nodes: [host :http://17.149.237.222:5540 time out : 300000]
Jul 2, 2013 2:50:33 PM org.openqa.grid.internal.BaseRemoteProxy getNewSession
INFO: Trying to create a new session on node host :http://17.149.237.222:5540 time out : 300000

I understand this issue is not with saunter, but I felt there is not much online literature on grid2...any help would appreciated.

- Thirumal

Carol Mirakove

unread,
Jul 8, 2013, 4:13:36 PM7/8/13
to sau...@googlegroups.com
To register a hub and a node independent of Saunter:

# in one terminal window, register a hub:
java -jar selenium-server-standalone-2.33.0.jar -role hub -maxInstances=4

# in another terminal window, register a node:
java -jar selenium-server-standalone-2.33.0.jar -role node -hub http://localhost:4444/grid/register -port 5555 -browserName=firefox,version=21,maxInstances=2,platform=MAC

When I do this, and I go to http://localhost:4444/grid/console, I see the node registered as expected.

To register a hub and a node within Saunter:

# configure a hub and a node in saunter.ini:

[Selenium]
manage_server: false
server_path: /path/to/selenium-server-standalone-2.33.0.jar
server_host: localhost
server_port: 4444
browser: firefox
chromedriver_path: /path/to/chromedriver
timeout: 8

[Selenium]
manage_server: false
server_path: /path/to/selenium-server-standalone-2.33.0.jar
server_host: localhost
server_port: 5555
browser: chrome
chromedriver_path: /path/to/chromedriver
timeout: 8

# ...

[Grid]
use_grid: true
type: selenium
platform: mac

# then, in one terminal window, register a hub:
java -jar selenium-server-standalone.jar -role hub 

# in another terminal window, register a node:
java -jar selenium-server-standalone.jar -role node

When I do this, and I run 
pysaunter -m "my_test_marks"
my tests are run by the node.

Does that help?

I am next going to troubleshoot how to configure Saunter to run tests in parallel. I'm not clear on how to do that from the blog post (http://element34.ca/blog/py-saunter-0-48-selenium-grid-parallel-execution-and-ci) so I'm going to dig into the code. If anyone has advice to share, it's most welcome.

Carol

Like us on Facebook: bitly | Bitly Enterprise
Follow us on Twitter: bitly | Bitly Enterprise
Follow us on LinkedIn
Add us on Google+

Carol Mirakove

unread,
Jul 9, 2013, 9:51:42 AM7/9/13
to sau...@googlegroups.com
I was successfully able to run tests in parallel by running pysaunter commands from different Terminal windows. I don't know if you've already worked out the trouble you were having, Thirumal, but in case this is useful, here's an update.

Grid and parallelization are basically working nicely by default (thanks, Adam). I am still working to understand the node configs, though. I *think* I probably want to establish the port and browser from the command line at runtime and set them as vars in the ini file, e.g.,

[Selenium]
manage_server: false
server_path: /path/to/selenium-server-standalone-2.33.0.jar
server_host: localhost
server_port: $PORT
browser: $BROWSER
chromedriver_path: /path/to/chromedriver
timeout: 8

then write some code to integrate the command line with saunter.ini. From my experiments, if you have multiple nodes in saunter.ini, e.g., 

[Selenium]
manage_server: false
server_path: /path/to/selenium-server-standalone-2.33.0.jar
server_host: localhost
server_port: 5555
browser: chrome
chromedriver_path: /path/to/chromedriver
timeout: 8

[Selenium]
manage_server: false
server_path: /path/to/selenium-server-standalone-2.33.0.jar
server_host: localhost
server_port: 5556
browser: safari
chromedriver_path: /path/to/chromedriver
timeout: 8

then only the last node is ever recognized (in this case, tests can only be run on port 5556 with Safari). There may be a way to set multiple port and browser combinations within one [Selenium] node section, but I'm not seeing that. It's cleaner to set them as vars anyway, methinks.

As for the Grid configs, the default config enough to achieve parallelization. If you want to parallelize more sessions than the Se Grid default maxSession (which is 5),  you should be able to add that as a var to 
/lib/site-packages/saunter/testcase/webdriver.py
and set it in saunter.ini.

Carol

Adam Goucher

unread,
Jul 9, 2013, 9:58:21 AM7/9/13
to sau...@googlegroups.com
This is exactly why the now-getting-silly-late-to-deliver switch to yaml
from .ini is happening.

thirumal rao

unread,
Jul 10, 2013, 3:23:43 AM7/10/13
to sau...@googlegroups.com
Thanks Carol. I was able to run hub and node. My objective of using grid was to achieve parallel execution and reduce time of run. Running saunter from multiple command-line windows works, but, this would mean I will get as many reports and logs as the number of threads. Anyway, for now, as Mary(Mary Ann May-Pumphrey) suggested, I will think of mutually exclusive -m queries and run them on multiple windows. 

Also, about the grid - Strangely, node did not register to the hub until hub host was explicitly mentioned.  Below is the command that worked for me - 

java -jar selenium-server-standalone-2.33.0.jar -host <IP address> -port 5555 -role node -hub http://<IP address of hub>:4444/grid/register -browser browserName=firefox,platform=MAC


I am yet to try multiple browsers. 

- Thirumal
Reply all
Reply to author
Forward
0 new messages