I am learning to use Selenium. So far, I succeeded in getting it to work. So, now I wanted to record navigation sequences using Selenium IDE, export them to python and run them.
This is the code I used.
from selenium import selenium
import unittest, time, re
#from pyvirtualdisplay import Display
class rc(unittest.TestCase):
def setUp(self):
self.verificationErrors = []
#self.display = Display(visible=0, size=(1024, 768))
#self.display.start()
self.selenium = selenium("localhost", 4444, "*chrome", "http://www.some-website.in")
self.selenium.start()
def test_rc(self):
sel = self.selenium
sel.click("link=Careers")
response = sel.get_title()
print response
def tearDown(self):
self.selenium.stop()
self.assertEqual([], self.verificationErrors)
#self.display.stop()
if __name__ == '__main__':
unittest.main()
The commented lines are manually added and were tried in case they worked (as they did in the previous basic example in which I just wanted selenium to work and resolve dependencies).
On running this auto-generated python code, I get:
File "mytest_test.py", line 34, in setUp
self.selenium.start()
File "/usr/local/lib/python2.7/dist-packages/selenium/selenium.py", line 202, in start
result = self.get_string("getNewBrowserSession", start_args)
File "/usr/local/lib/python2.7/dist-packages/selenium/selenium.py", line 237, in get_string
result = self.do_command(verb, args)
File "/usr/local/lib/python2.7/dist-packages/selenium/selenium.py", line 226, in do_command
conn.request("POST", "/selenium-server/driver/", body, headers)
File "/usr/lib/python2.7/httplib.py", line 973, in request
self._send_request(method, url, body, headers)
File "/usr/lib/python2.7/httplib.py", line 1007, in _send_request
self.endheaders(body)
File "/usr/lib/python2.7/httplib.py", line 969, in endheaders
self._send_output(message_body)
File "/usr/lib/python2.7/httplib.py", line 829, in _send_output
self.send(msg)
File "/usr/lib/python2.7/httplib.py", line 791, in send
self.connect()
File "/usr/lib/python2.7/httplib.py", line 772, in connect
self.timeout, self.source_address)
File "/usr/lib/python2.7/socket.py", line 571, in create_connection
raise err
error: [Errno 111] Connection refused
Help?