0 votes
1 view
in DevOps and Agile by (30k 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 (51.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.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !