1

I'm working on a gui that takes in values and runs a Selenium test based on those values. I decided to run the selenium stuff as a thread because it would make the gui unresponsive. The only problem is no waiting is happening. It's as if the wait weren't even there at all. I'm assuming the fact that it's being run as a thread is preventing the waits from running because I've used waits before without any problem. I always see people ask for code on here, but there's really nothing to show.

Here's how I start the thread:

def selenium_stuff():
    ...

t = threading.Thread(target=selenium_stuff)
t.start()

And here's how I call the wait

self.driver.implicitly_wait(20)

So I guess my question is: Are selenium tests that run as threads unable to wait? If not, what's most likely going wrong? Thanks in advance for any help.

I'm running this on windows 8 regrettably, using chromedriver v2.14 and Selenium v2.45.0 with Python 2.7.5

UPDATE

Here is a minimal example to run

from selenium import webdriver
import threading

def selenium_stuff():
    driver = webdriver.Chrome()
    driver.get('http://google.com')
    driver.implicitly_wait(20)
    search = driver.find_element_by_id("lst-ib")
    search.send_keys('help me')
    button = driver.find_element_by_id("tsf")
    button.click()

t = threading.Thread(target=selenium_stuff)
t.start()
James Robert Albert
  • 404
  • 1
  • 5
  • 13
  • If one thread waits, the other threads will run unimpeded, generally speaking. Otherwise, you'd make the GUI unresponsive. Without seeing *more* of your code (ideally a minimal complete example that I can run in Python myself), it's hard to say whether that's the problem. – Kevin Mar 24 '15 at 19:00
  • @Kevin Thanks for the reply. Although I added an example after I saw your response, I also magically found the solution after days of glazing over my screen. time.sleep() is the solution. – James Robert Albert Mar 24 '15 at 19:20

0 Answers0