I've been baffled by why this simple setup is failing on me, hope someone here can shed some light.
My goal is to be able to run all the testcases in every test suite, and if a testcase fails in one suite, RF should allow the other tests and any subsequent test suites to run with a fresh browser session. My test teardown is not working correctly when one testcase fails (both Close All Browsers and Close Browser did not work for me). Log and code samples attached below.
My test structure is this:
keywords/
common.txt
test_scripts/
__init__.txt
feature1/
testsuite1/
testcase1.txt
testsuite2/
testcase2.txt
------------------------------------------------------------------
common.txt contains this:
*Settings*
Library Selenium2Library
*Keyword *
My Test Setup
Log My Test Setup
Maximize Browser Window
Delete All Cookies
Sleep 5
My Test Teardown
Sleep 5
Close Browser
------------------------------------------------------------------
__init__.txt contains this:
*** Settings***
Resource ${CURDIR}/../../keywords/common.txt
Suite Setup My Suite Setup
Suite Teardown My Suite Teardown
Test Setup My Test Setup
Test Teardown My Test Teardown
*** Variables ***
*Keyword*
My Suite Setup
Log my suite setup
Set Selenium Timeout 60
My Suite Teardown
Log my suite tear down
Close All Browsers
--------------------------------------------------
All the testcase*.txt have similar content (I purposely cause failures to force the test teardown/suite teardown problem):
*Settings*
Resource ${CURDIR}/../../../keywords/common.txt
Test Setup My Test Setup
Test Teardown My Test Teardown
*Test Cases*
Simple Test 1.1
Page Should Contain Loan
Sleep 2
Simple Test 1.2
Page Should Contain Weather
Sleep 2
-------------------------------------------
I ran the test with loglevel set to trace. The page does not contain the word 'Loan' and it fails as I had intended.
Robot tries to capture page screenshot because the page does not contain 'Loan', but it cannot take screenshot, and then close browser call also fails.
Why is it doing that?
20:01:13.582 DEBUG Closing browser with session id 83a06c543af1f09c208982d1ec1de7ae
20:02:08.942 WARN Keyword 'Capture Page Screenshot' could not be run on failure: URLError: <urlopen error [Errno 10061] No connection could be made because the target machine actively refused it>
20:02:08.952 FAIL WindowsError: [Error 5] Access is denied
20:02:08.952 DEBUG Traceback (most recent call last):
File "<string>", line 2, in close_browser
File "C:\Python27\lib\site-packages\Selenium2Library\keywords\keywordgroup.py", line 12, in _run_on_failure_decorator
return method(*args, **kwargs)
File "C:\Python27\lib\site-packages\Selenium2Library\keywords\_browsermanagement.py", line 50, in close_browser
self._cache.close()
File "C:\Python27\lib\site-packages\Selenium2Library\utils\browsercache.py", line 23, in close
browser.quit()
File "C:\Python27\lib\site-packages\selenium-2.20.0-py2.7.egg\selenium\webdriver\chrome\webdriver.py", line 76, in quit
self.service.stop()
File "C:\Python27\lib\site-packages\selenium-2.20.0-py2.7.egg\selenium\webdriver\chrome\service.py", line 94, in stop
os.kill(self.process.pid, signal.SIGTERM)