Loop Automation Script?

Hi All.

I am using Chromedriver to automate a form but I want to loop my code so that it
runs infinitely.

E.g – Reloads page, runs code and repeats.  How can I achieve this with what i have so far?

 


from selenium import webdriver

from selenium.webdriver.common.keys import Keys

from selenium.webdriver.common.by import By

browser = webdriver.Chrome()
browser.get("http://www.site.com/dropdown/form")
elem = browser.find_element_by_id('quantity');

elem.send_keys('2');

elem = browser.find_element_by_id('area');

elem.send_keys('mobile' + Keys.RETURN);

elem = browser.find_element_by_id('submit-button');

elem.send_keys(Keys.RETURN);

Default Asked on February 4, 2016 in Selenium WebDriver.
Add Comment
  • 1 Answer(s)

    Nice to see some Python snippet.

    Well, when you speak the word- Indefinite then it will raise some eyebrows.

    In Java we could do something like:

    
    while (1) {
    
    //Do whatever you want to do
    
    }
    
    

    But proper way to achieve it will be use CI like- Jenkins
    > Install Jenkins on server
    > Go to your test
    > Convert it into Maven runnable test
    [In case of Python make it runnable using PIP, i guess]
    > Call executable using Shell or windows batch file
    I guess in your case:

    Train Answered on February 4, 2016.
    Add Comment
  • Your Answer

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