I'm learning automation with selenium and I'm a bit blocked at the moment with one element. I don't know why it is considered as not visible but elements similar to this one on another part of the website are considered as visible and I don't experience any issue to click on them.
To present you the concerned part, this is how it looks:
It's a calendar with different shifts, there are three separated parts.
When I try to click on the orange shift, I have an error which tells me that this element isn't visible. But on my other scripts which perform the same kind of action but on the other shifts it works well
My script is the following one:
# Check if the shift is on the schedule or not.
if (len(admin.find_elements_by_xpath("//div[@data-shift-date='%s']/div/div[@class='shift-details']" %date))!=0 ):
print "The unassigned shift is scheduled, good"
else:
print "The unassigned shift is not scheduled, issue"
sauce_client.jobs.update_job(admin.session_id, passed=False)
admin.quit();
sys.exit()
# The part above works
# Publish the shift
# Open the shift
element = admin.find_element_by_xpath("//div[@data-shift-date='%s']/div/div[@class='shift-details']" %date)
actions.move_to_element(element)
actions.click(element)
actions.perform()
admin.implicitly_wait(10)
Even if I try this way it doesn't work:
# Publish the shift
# Open the shift
admin.find_element_by_xpath("//div[@data-shift-date='%s']/div/div[@class='shift-details']" %date).click()
admin.implicitly_wait(10)
The HTML of the orange element is the following one:
The error:
Traceback (most recent call last):
File ".\Unassigned_shift_basics.py", line 84, in <module>
admin.find_element_by_xpath("//div[@data-shift-date='%s']" %date).click()
File "C:\Python27\lib\site-packages\selenium-3.0.2-py2.7.egg\selenium\webdriver\remote\webelement.py", line 77, in cli
ck
self._execute(Command.CLICK_ELEMENT)
File "C:\Python27\lib\site-packages\selenium-3.0.2-py2.7.egg\selenium\webdriver\remote\webelement.py", line 494, in _e
xecute
return self._parent.execute(command, params)
File "C:\Python27\lib\site-packages\selenium-3.0.2-py2.7.egg\selenium\webdriver\remote\webdriver.py", line 236, in exe
cute
self.error_handler.check_response(response)
File "C:\Python27\lib\site-packages\selenium-3.0.2-py2.7.egg\selenium\webdriver\remote\errorhandler.py", line 192, in
check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementNotVisibleException: Message: element not visible
(Session info: chrome=55.0.2883.75)
(Driver info: chromedriver=2.27.440174 (e97a722caafc2d3a8b807ee115bfb307f7d2cfd9),platform=Mac OS X 10.11.6 x86_64)
date
is what you think it is?