1

I had a file upload functionality, which worked very well by using below code

self.driver.find_element_by_xpath('some_xpath').send_keys('/tmp/my_file.csv')

But now due to some recent changes, i cannot find this element by xpath. Few components are merged in angular and xpath approach wont work now.

I am able to click on file upload button using actions:

el = self.driver.find_element_by_xpath("some_other_xpath_which_i_can_find")
action = webdriver.common.action_chains.ActionChains(self.driver)
action.move_to_element_with_offset(el, 150, 70).click().perform()

This opens file selection modal successully.

However, send key does not work.

el = self.driver.find_element_by_xpath("some_other_xpath_which_i_can_find")
action = webdriver.common.action_chains.ActionChains(self.driver)
action.move_to_element_with_offset(el, 150, 70).send_keys("/tmp/my_file.csv").perform()

I am getting this error:

AttributeError: 'ActionChains' object has no attribute "'id'"

I am struggling to solve this for hours. Tried everything available on internet. Please guide.

Saurabh Shrivastava
  • 1,394
  • 4
  • 21
  • 50
  • SOLVED by using drag drop approach: https://stackoverflow.com/questions/43382447/python-with-selenium-drag-and-drop-from-file-system-to-webdriver – Saurabh Shrivastava Nov 21 '19 at 12:03

0 Answers0