Help with Python and Selenium

0

I work with server monitoring and whenever a service crashes, I need to click on a link to be responsible for the server. I was able to create a script in Python + Selenium that accesses the monitoring page and is clicking every 5 seconds on the "Analyze Server" button. But I have one thing that bothers me and another that is a problem:

  • I do not think the script is too smart to just click on the link every 5 seconds. I would like it to identify when the status is as "Off" it marks the server;

  • Even with while True: or by putting a while (conta <= 10800): it is running at most 20 minutes;

  • Here is the code:

    from selenium import webdriver # importa a biblioteca
    from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
    import time
    
    capabilities = DesiredCapabilities.FIREFOX.copy()# fazendo ficar compativel com a versão atual do Firefox
    
    capabilities['marionette'] = False # a instancia .get serve para direcionar um open ao webdriver, após ela você insere o website que deseja abrir
    
    browser = webdriver.Firefox(capabilities=capabilities)
    browser.get('minha-url')
    
    def marca_servidor():
    
            time.sleep(5)
            browser.get('minha-url')
            resp = browser.find_element_by_xpath('meu-xpath1')
            resp.click()
    
    conta = 0
    
    while (conta <= 1080000):
        conta += 1
        marca_servidor()
    
        
    asked by anonymous 25.05.2018 / 01:30

    0 answers