0

Trying to click this button id="btnSearch"

I'm trying to click on this button: browser.find_element_by_id('btnSearch')

But this button is blocking by this div tag: <div id="actionSearch" class="row pull-right">

How do I go around to click this button with id='btnSearch" while it's blocking by the actionSearch div?

I tried the following:

  • browser.find_element_by_id('btnSearch').click()

  • browser.implicitly_wait(10)
    el = browser.find_element_by_xpath('//*[@id="btnSearch"]')
    ActionChains(browser).move_to_element_with_offset(el, 1827, 270)
    ActionChains(browser).click()
    ActionChains(browser).perform()
    
  • element = browser.find_element_by_id('btnSearch')
    browser.execute_script("arguments[0].click();", element)
    
  • wait(browser, 10).until(EC.element_to_be_clickable((By.XPATH, //*[@id="btnSearch"]'))).click()
    

none of these work.

Can anyone help me with this? I've spent two days trying to click this button!! Please help!

Blue Moon
  • 189
  • 1
  • 11
  • What exceptions occurs for the different options you tried? – Frank Mar 06 '18 at 10:41
  • Possible duplicate of [Element MyElement is not clickable at point (x, y)... Other element would receive the click](https://stackoverflow.com/questions/44724185/element-myelement-is-not-clickable-at-point-x-y-other-element-would-receiv) – undetected Selenium Mar 06 '18 at 11:43
  • Check this [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/44916498#44916498) – undetected Selenium Mar 06 '18 at 11:53
  • To find out if it is a duplicate, at least it must be known which exception occurs. – Frank Mar 06 '18 at 12:36

1 Answers1

0

Considering provided image of HTML source (tip: do not provide it as image, but as text instead) I can assume that required element located in the bottom of page and you might need to scroll page down to be able to handle it.

Try below code

link = browser.find_element_by_id("btnSearch")
browser.execute_script("arguments[0].scrollIntoView()", link)
link.click()

Note that link is not a pseudo-element (is not located inside ::before/::after pseudo-element), so it can not be the cause of your problem

As for your code:

ActionChains(browser).move_to_element_with_offset(el, 1827, 270)
ActionChains(browser).click()
ActionChains(browser).perform()

Here you're trying to make scroll to link with huge offset and then you make click on current mouse position - not on link

You can try to modify it as

ActionChains(browser).move_to_element(el)
ActionChains(browser).click(el)  # Pass WebElement you want to click as argument to `click()`
ActionChains(browser).perform()
Andersson
  • 51,635
  • 17
  • 77
  • 129
  • Thanks you for taking your time to answer! I'll try this tomorrow when I get back to work. I just found out that the reason the element is not clickable is because the above div id= "actionSearch" is blocking the button that i'm trying to click. I really hope your solution work. Can't wait to try it tomorrow. – Blue Moon Mar 06 '18 at 06:59
  • It didn't work. I got this: essage: unknown error: Element ... is not clickable at point (1827, 270). Other element would receive the click:
    – Blue Moon Mar 06 '18 at 17:13
  • Can you try to add `wait(browser, 10).until_not(EC.visibility_of_element_located((By.XPATH, //div[@class="k-overlay"]')))` before handling link? – Andersson Mar 06 '18 at 17:19
  • Not sure if i add it correctly: Here what i did: `wait(browser, 10).until_not(EC.visibility_of_element_located((By.XPATH, '//div[@class="k-overlay"]'))) link = browser.find_element_by_id("btnSearch") browser.execute_script("arguments[0].scrollIntoView()", link) link.click()` Error Message: `-> 132 wait(browser, 10).until_not(EC.visibility_of_element_located((By.XPATH, '//div[@class="k-overlay"]'))) ---> 96 raise TimeoutException(message)TimeoutException: Message:` – Blue Moon Mar 06 '18 at 18:35
  • It's hard to tell for sure how to solve the issue since I cannot fully understand the behavior of target web-app? Can you share page URL or it's not public? – Andersson Mar 06 '18 at 18:42
  • Sorry it's not public. I think there is other component overlapping here (some other component of the DOM) The second answer of this thread give some possible solutions, but it's in java. I don't know java. https://stackoverflow.com/questions/44724185/element-myelement-is-not-clickable-at-point-x-y-other-element-would-receiv Anyway thanks you for taking your time to help! – Blue Moon Mar 06 '18 at 19:02
  • Yep, obviously something overlapping the link :) The problem is how to get rid of click interception... I see `
    ` on your image and it's right above the link. Can you check how it looks like when page rendered? Does it has fixed position just like the navigation bar on this SO page? Do you need to scroll little more to see the link?
    – Andersson Mar 06 '18 at 19:10
  • I uploaded two pictures here: https://imgur.com/a/njo3c When I hover on the '
    ' the whole thing highlight. When I hover on the '
    , both search and Reset are highlight. I think that's the reason I can't on search button?
    – Blue Moon Mar 06 '18 at 20:03
  • Can you try this little hack `driver.execute_script('document.querySelector("div.k-overlay").display="none";')` instead of `wait(browser, 10).until_not(EC.visibility_of_element_located((By.XPATH, //div[@class="k-overlay"]')))` ? – Andersson Mar 06 '18 at 20:14
  • Error Message: `... is not clickable at point (1827, 270). Other element would receive the click:
    ` I used this: `browser.execute_script('document.querySelector("div.k-overlay").display="none";') link = browser.find_element_by_id("btnSearch")browser.execute_script("arguments[0].scrollIntoView()", link) link.click()`
    – Blue Moon Mar 06 '18 at 20:32
  • I really appreciate you taking time to help figuring this out! – Blue Moon Mar 06 '18 at 20:34
  • Oh, sorry, it should be `browser.execute_script('document.querySelector("div.k-overlay").style.display="none";')` – Andersson Mar 06 '18 at 20:36
  • Still couldn't click it. Is it possible to disable style on this `
    `?
    – Blue Moon Mar 06 '18 at 20:49
  • Another suggestion: just try to replace `link.click()` with `browser.execute_script('arguments[0].click();', link)` – Andersson Mar 06 '18 at 20:52