Reputation: 650
I am trying to test a chat application that need two different browser sessions. I tried this in the following way:
Following is the code:
from selenium import selenium
from selenium import webdriver
from threading import Thread
import unittest, time, re
import time
class envolveChatCheck(unittest.TestCase):
def get_sauce_browser(self, port=4444, browser="*firefox"):
return selenium('localhost', port, browser, 'http://example.com/')
def get_browser_and_wait(self, browser, browser_num):
print "starting browser %s" % browser_num
browser.start()
browser.open("/")
print "browser %s ready" % browser_num
def setUp(self):
self.verificationErrors = []
self.b1 = self.get_sauce_browser(browser='*googlechrome', port=4444)
self.b2 = self.get_sauce_browser(browser='*firefox', port=4444)
print "all browsers ready"
def test_envolve_chat_check(self):
print "starting b1"
self.b1.start()
print "starting b2"
self.b2.start()
print "opening homepage b1"
self.b1.open("/")
self.b1.wait_for_page_to_load("30000")
print "opening homepage b2"
self.b2.open("/")
self.b2.wait_for_page_to_load("30000")
def tearDown(self):
self.b1.stop()
self.b2.stop()
self.assertEqual([], self.verificationErrors)
if __name__ == "__main__":
unittest.main()
Following is the error I am getting:
Traceback (most recent call last):
File "envolveChatCheck.py", line 32, in test_envolve_chat_check
self.b1.open("/")
File "/usr/local/lib/python2.6/dist-packages/selenium/selenium.py", line 774, in open
self.do_command("open", [url,ignoreResponseCode])
File "/usr/local/lib/python2.6/dist-packages/selenium/selenium.py", line 214, in do_command
raise Exception, data
Exception: ERROR: Got a null result
Any hints about this?
Upvotes: 2
Views: 4153
Reputation: 141
My suggestion would be to run your script in Jenkins(Hudson) using a multi-config project
In the python block you can insert your code and to pull the browser values set earlier:
#!/usr/bin/python
import os
BROWSER = os.getenv('BROWSERS')
What happens is that Jenkins will create separate jobs using the values of defined in the Axis created earlier and your python script will have that value injected for each job.
You can further extend this with other methods but this will at least help you focus on the test case logic and not worry as much about execution. The example above was based on Linux.
Note: I use SeleniumGrid plugin with a Windows slave to run my IE test scripts from Linux.
Upvotes: 5