2

We are using Robot Framework for writing/automating acceptance test cases.

Every time i need to run the whole script to check the last lines of code of my script, That Wastes lot of time and creates lots of duplicate records in the system, i just wanted to avoid re-running whole script to check last lines of code and resume the execution from the point where it erred in previous run.

That is to say;If the test run throws error; it will not just close the browser window; And next run will use the same browser window with next command in sequence after which it had failed in last run.

1

2 Answers 2

2

What you ask is not directly possible with Robot/Selenium, but from what you write, I can see room for some improvements:

  • "creates lots of duplicate records in the system" => you should have Teardown in your tests that clean the system when the tests are finished (and teardown are run even when there is a failure). So next time you run the tests, the system starts clean
  • "That Wastes lot of time" => if your tests are too long to run, maybe you should consider splitting them in smaller chunks. And also consider running part of your tests directly via the REST or SOAP interface instead of the browser.
Sign up to request clarification or add additional context in comments.

1 Comment

I'll counter your second point - during development, I find it very usable to reuse an open browser - it saves me 20-30s for reinstantiating, navigation and the backend data retrieval the SUT does. That mostly coincides with OP desired behaviour- resuming an execution from the last failure/termination point. I have to say it though - for production usage this should be done only with very sound reasoning, and extra precautions.
1

Here is a geckodriver example for Firefox (win)

Start your Firefox with marionette enabled (standard port is 2828)

"C:\Program Files\Mozilla Firefox\firefox.exe" --marionette

Robot example script

*** Settings ***
Library           SeleniumLibrary

*** Variables ***
${BROWSER}          Firefox
${GECKODRIVER EXE}  c:/MY_GECKODRIVER_PATH/geckodriver.exe
${GECKODRIVER LOG}  C:/MY_GECKODRIVER_LOG_PATH/log.txt

*** Test Cases ***
Firefox Browser Test
    Init Webdriver
    Go To   https://www.google.com
    
*** Keywords ***
Init Webdriver
    ${service_args}=     Create List    --connect-existing    --marionette-port=2828    --marionette-host=127.0.0.1
    Create Webdriver     ${BROWSER}        executable_path=${GECKODRIVER EXE}   service_args=${service_args}    service_log_path=${GECKODRIVER LOG}

-- Chrome example --

Start Chrome with remote debugging enabled (port is 9222)

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222

Robot example script

*** Settings ***
Library           SeleniumLibrary
Library           Collections

*** Variables ***
${BROWSER}          Chrome

${CHROMEDRIVER EXE}  c:/MY_CHROMEDRIVER_PATH/chromedriver93.exe
${CHROMEDRIVER LOG}  c:/MY_CHROMEDRIVER_LOG_PATH/chromedriver_log.txt


*** Test Cases ***
Chrome Browser Test
    Init Webdriver
    Go To   https://stackoverflow.com

*** Keywords ***
Init Webdriver
    ${service_args}=        Create List   --log-path=${CHROMEDRIVER LOG}  --verbose
    ${chromeOptions}=       Evaluate    sys.modules['selenium.webdriver'].ChromeOptions()  sys,selenium.webdriver 
    ${chromeCapabilities}=  Call Method   ${chromeOptions}   to_capabilities
    Set To Dictionary       ${chromeCapabilities["goog:chromeOptions"]}   debuggerAddress   127.0.0.1:9222
    Create WebDriver        ${BROWSER}   desired_capabilities=${chromeCapabilities}   executable_path=${CHROMEDRIVER EXE}   service_args=${service_args}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.