1

I need to click this HTML with :

<span title="Klik for at oprette booking" onclick="sende('proc_straks.asp','opret','11-02-2018;1;18;20:00;20:45;0;','','', '046009a83941f411fb90c9790a0c92a8')" style='height:52px;' class='banefelt btn_ledig link '>
<div class='padding5'>
<div>20:00 - 20:45</div>
<div class='clearfix'>
</div>
</div>
</span>

So I tried this code:

for i in range(1500):
    if driver.find_elements_by_tag_name("div")[i].text == '20:00 - 20:45':    
        diven = driver.find_elements_by_tag_name("div")[i]
        diven.find_element_by_xpath('..').click()

and I got this error:

selenium.common.exceptions.WebDriverException: Message: 
unknown error: Element <span title="Klik for at oprette booking" 
onclick="sende('proc_straks.asp','opret',
'10-02-2018;1;18;20:00;20:45;0;','','', 
'2e24985c6c1be987e1ab481b1588c28a')" style="height:52px;" 
class="banefelt btn_ledig link ">...</span> 
is not clickable at point (172, 611). 
Other element would receive the click: <p class="cc_message">...</p>e click:
Nae
  • 14,209
  • 7
  • 52
  • 79
Kresten
  • 810
  • 13
  • 36
  • 1
    possible duplicate of : https://stackoverflow.com/questions/11908249/debugging-element-is-not-clickable-at-point-error – JacobIRR Feb 09 '18 at 21:38
  • 1
    Possible duplicate of [Debugging "Element is not clickable at point" error](https://stackoverflow.com/questions/11908249/debugging-element-is-not-clickable-at-point-error) – Stack Feb 09 '18 at 21:39
  • that looks like there's some sort of message ("cc_message") dialog that's displayed over your target div. are there ads or something popping up? – Breaks Software Feb 09 '18 at 22:50
  • Possible duplicate of [Selenium Web Driver & Java. Element is not clickable at point (36, 72). Other element would receive the click:](https://stackoverflow.com/questions/44912203/selenium-web-driver-java-element-is-not-clickable-at-point-36-72-other-el) – undetected Selenium Feb 10 '18 at 11:13

2 Answers2

1

I assume you want to click the span element, so how about doing it this way:

span_list = driver.find_elements_by_tag_name("span")

for span in span_list:

    iterate_through_span_list = True

    div_list = span.find_elements_by_tag_name("div")

    for div in div_list:

        if div.text == '20:00 - 20:45':

            span.click()

            iterate_through_span_list = False

            break

    if iterate_through_span_list == False:

        break
RKelley
  • 1,099
  • 8
  • 14
0

You use an indirect way to find your wanted span, why not find the span directly, but use an outer for loop from 1 to 1500

spans = driver
    .find_elements_by_css_selector("span[title*='oprette booking']")

for span in spans:
  time_slot = span
    .find_element_by_css_selector("div.padding5 + div").text

  if time_slot == '20:00 - 20:45':
    span.click()
    break

not clickable is know issue on chromedriver 2.31 when element not visible in current viewport, if you use this version, please upgrade to 2.33 or later.

If no matter with chromdriver version, check is there anything covered the span.

yong
  • 13,357
  • 1
  • 16
  • 27
  • I found that I had to click away an accept cookies pop up. Then it worked. My version of chromedriver is already 2.33. – Kresten Feb 10 '18 at 21:47