0
votes

I was trying to open stackoverflow and search for a query and then click the search button. almost everything went fine except I was not able to click submit button

I encountered error

WebDriverException: unknown error: Element ... is not clickable at point (608, 31). Other element would receive the click: (Session info: chrome=60.0.3112.101) (Driver info: chromedriver=2.29.461591 (62ebf098771772160f391d75e589dc567915b233),platform=Windows NT 6.1.7601 SP1 x86)

 browser=webdriver.Chrome()
    browser.get("https://stackguides.com/questions/19035186/how-to-select-element-with-selenium-python-xpath")
    z=browser.find_element_by_css_selector(".f-input.js-search-field")#use .for class and replace space with .
    z.send_keys("geckodriver not working")
    submi=browser.find_element_by_css_selector(".svg-icon.iconSearch")
    submi.click()
3
The element is probably moved away by a css hover effect or javascript. Or some other element consumes the click event. I would just try another dom element to submit the click event on. #search input, for instance. - Håken Lid
i am anaware of css hover or dom element - Nimish Bansal
You should research that, then. It's very useful to know the basics of how a browser works when you use Selenium. - Håken Lid

3 Answers

2
votes
<button type="submit" class="btn js-search-submit">
    <svg role="icon" class="svg-icon iconSearch" width="18" height="18" viewBox="0 0 18 18">
        <path d="..."></path>
    </svg>
</button>

You are trying to click on the svg. That icon is not clickable, but the button is.

So change the button selector to .btn.js-search-submit will work.

2
votes

Use below code to click on submit button:

browser.find_element_by_css_selector(".btn.js-search-submit").click()
1
votes

Click the element with right locator, your button locator is wrong. Other code is looking good

try this

browser=webdriver.Chrome()
browser.get("https://stackguides.com/questions/19035186/how-to-select-element-with-selenium-python-xpath")
z=browser.find_element_by_css_selector(".f-input.js-search-field")#use .for class and replace space with .
z.send_keys("geckodriver not working")
submi=browser.find_element_by_css_selector(".btn.js-search-submit")
submi.click()