0

Please bear with me, I'm new to both Python and Webdriver, but I'm having trouble getting ActionChains to work when inside a function.

Running this is fine: -

wait.until(ec.presence_of_element_located((By.XPATH, "//*[@id='bulk-upload-patient-spreadsheet']/div[1]/div/div/div/table/tbody/tr[2]/td[1]"))).click()
actions = ActionChains(driver)
actions.send_keys("test")
actions.perform()

..but running this causes an error: -

def test_function(self):
    wait = initialisation.wait_for(self.driver)
    self.driver = login.default_login(self.driver)
    wait.until(ec.presence_of_element_located((By.XPATH, "//*[@id='bulk-upload-patient-spreadsheet']/div[1]/div/div/div/table/tbody/tr[2]/td[1]"))).click()
    actions = ActionChains(self.driver)
    actions.send_keys("test")
    actions.perform()

The error I get is: -

AttributeError: 'NoneType' object has no attribute 'w3c'

Any help would be greatly appreciated...

Northers
  • 85
  • 1
  • 13
  • I'm testing on Chrome and I've just noticed that the above code works fine on Firefox, is this an issue with Chrome? Is there a workaround? – Northers Nov 23 '17 at 13:37
  • This has been answered by another question I'd posted. I am calling the login.default_login function inside test_function and this had no return statement so was returning None. I added a return statement and now it works as expected. – Northers Nov 27 '17 at 08:43

0 Answers0