0

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.

Árpád Magosányi
  • 1,394
  • 2
  • 19
  • 35
  • 1. What is actual value of `elementId`? 2. Why you send space to checkbox instead of clicking it? 3. What is the reason to use this weird loop? If checkbox is not selected you just waste 10 seconds – Andersson Oct 20 '16 at 20:08
  • elementId in this instance is "registration-form_confirmField", which is the id of the checkbox element on the page. The reason for the weird loop is to make sure that the element is actually checked before moving on. This actually made the test stable on my own machine... The reason for sending space is that there was a selenium version where click did not work. I have changedback to click and got rid of the loop. Works in my machine, waiting for shippable. – Árpád Magosányi Oct 20 '16 at 20:18
  • I got "No JSON object could be decoded" in the selenium test for the click. – Árpád Magosányi Oct 20 '16 at 20:32
  • http://stackoverflow.com/questions/14682763/how-to-select-checkboxes-using-selenium-java-webdriver the reason for sending space. – Árpád Magosányi Oct 20 '16 at 20:42
  • W hat do you mean there was a selenium version where click did not work?? Could you tell what version of selenium are you using where `WebElement#click()` doesn't work?? – Saurabh Gaur Oct 21 '16 at 00:07
  • I don't know what "on shippable" means, but I'm speculating that it's a different test environment. Did your automated test actually find a product bug here? Maybe you should look at that check box manually in the test environment where the automated test if failing. – Breaks Software Oct 21 '16 at 19:53
  • shippable is shippable.com. my shippable configuration instructs shippable to run in the same docker container (coming from hub.docker) in which I am testing on my machine. I cannot imagine how can be a difference in the software environment – Árpád Magosányi Oct 23 '16 at 19:53

0 Answers0