Explore Courses Blog Tutorials Interview Questions
0 votes
in DevOps and Agile by (29.3k points)

I am quite new to python selenium and I am trying to click on a button which has the following html structure:

<div class="b_div">

    <div class="button c_button s_button" onclick="submitForm('mTF')">

        <input class="very_small" type="button"></input>

        <div class="s_image"></div>





    <div class="button c_button s_button" onclick="submitForm('rMTF')" style="margin-bottom: 30px;">

        <input class="v_small" type="button"></input>






I would like to be able to click both the Search and Reset buttons above (obviously individually).
I have tried a couple of things, for example:
driver.find_element_by_css_selector('.button .c_button .s_button').click()
but, I seem to always end up with NoSuchElementException, 
for example:
selenium.common.exceptions.NoSuchElementException: Message: u'Unable to locate element: {"method":"name","selector":"s_image"}' ;
I am wondering if I can somehow use the onclick attributes of the HTML to make selenium click?
Any thoughts which can point me in the right direction would be great. Thanks.

1 Answer

0 votes
by (50.2k points)

For this query remove the spaces between classes in css selector


And check your answer if you still got same error go through 

print(driver.page_source) and check the name, mostly error will be with the name, if you have a different name please rename it to which you are calling and retry it. Hope it will help you.

If you wish to Learn Selenium visit this Selenium Webdriver Tutorial and Selenium Webdriver Interview Questions by Intellipaat.

If you are interested to learn Selenium on a much deeper level and want to become a professional in the testing domain, check out Intellipaat’s Selenium course!

Browse Categories