Nimish Bansal
Nimish Bansal

Reputation: 1759

submit element not clickable selenium python

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://stackoverflow.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()

Upvotes: 0

Views: 1550

Answers (3)

kanishk
kanishk

Reputation: 91

Use below code to click on submit button:

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

Upvotes: 2

iamsankalp89
iamsankalp89

Reputation: 4739

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

try this

browser=webdriver.Chrome()
browser.get("https://stackoverflow.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()

Upvotes: 1

xmcp
xmcp

Reputation: 3742

<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.

Upvotes: 2

Related Questions