Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

I am trying to run a series of tests using selenium webdriver using a loop.

Code snippet I am using.

for var in range(2,worksheet.nrows+1):

When I run the program, the first test case gets executed successfully. But the next test case fails with the error

ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it

Can someone help me if you have come across this issue. I am using Selenium webdriver 2.39.0

The whole error log:

* Traceback (most recent call last): File "C:/Users/xrankum/PycharmProjects/Modules/execute_action.py", line 82, in test.execute_action() File "C:/Users/xrankum/PycharmProjects/Modules/execute_action.py", line 48, in execute_action action_definitions().navigate_to_lineaction_page(matrix[var]) File "C:\Users\xrankum\PycharmProjects\Modules\action_definitions.py", line 49, in navigate_to_lineaction_page peoplesoft_main_page().login_to_peoplesoft(environment,country) File "C:\Users\xrankum\PycharmProjects\Modules\peoplesoft_main_page.py", line 18, in login_to_peoplesoft browser.get("website I am working on") File "C:\Python33\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 176, in get self.execute(Command.GET, {'url': url}) File "C:\Python33\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 162, in execute response = self.command_executor.execute(driver_command, params) File "C:\Python33\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 349, in execute return self._request(url, method=command_info[0], data=data) File "C:\Python33\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 376, in _request self._conn.request(method, parsed_url.path, data, headers) File "C:\Python33\lib\http\client.py", line 1065, in request self._send_request(method, url, body, headers) File "C:\Python33\lib\http\client.py", line 1103, in _send_request self.endheaders(body) File "C:\Python33\lib\http\client.py", line 1061, in endheaders self._send_output(message_body) File "C:\Python33\lib\http\client.py", line 906, in _send_output self.send(msg) File "C:\Python33\lib\http\client.py", line 844, in send self.connect() File "C:\Python33\lib\http\client.py", line 822, in connect self.timeout, self.source_address) File "C:\Python33\lib\socket.py", line 435, in create_connection raise err File "C:\Python33\lib\socket.py", line 426, in create_connection sock.connect(sa) ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it *

share|improve this question
Sounds like a firewall issue. –  l19 Jan 17 at 3:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.