proper way to tick a checkbox in selenium?

时间:2016-10-20 19:52:10

标签: python selenium checkbox

I want to tick a checkbox in a selenium test using python. The test passes all times when I run it on my local machine, and fails all times when I run it using shippable. The test runs in a docker container, so there should not be any difference. The code:

def tickCheckbox(self, elementId):
    self.logAction('<tickCheckbox fieldid="{0}">'.format(elementId))
    element = TE.driver.find_element_by_id(elementId)
    element.send_keys(Keys.SPACE)
    print elementId
    selected = False
    for t in range(10):
        time.sleep(1)
        print "slept"
        if element.is_selected():
            selected = True
            break
    self.assertTrue(selected)

On shippable it fails on the last line.

0 个答案:

没有答案