[Python] selenium click on button

如果html 長這樣子:

<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>
        <span>
           Search
        </span>
    </div>

    <div class="button c_button s_button" onclick="submitForm('rMTF')" style="margin-bottom: 30px;">
        <input class="v_small" type="button"></input>
        <span>
              Reset
        </span>
   </div>

</div>

錯誤解法:(有空格)

driver.find_element_by_css_selector('.button .c_button .s_button').click()

正解:

driver.find_element_by_css_selector('.button.c_button.s_button').click()

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *