我试图点击网页界面中的按钮,但正常的点击功能失败,所以我试图执行javascript,但无济于事。任何指针都会受到赞赏。
按钮名为THISBUTTON
代码
<div class="tab_middle clearfix" id="tab_middle2">
<div class="tab_icon" id="tab_icon2"></div>
<div class="tab_title editable" id="tab_title2" data="{"columns":"2","allowConfig":true,"allowClose":true,"fixedColumn":null,"eventCode":"null","pageNumber":2,"isPreset":false,"name":"THISBUTTON","boxWidth":"1220:209","autoFit":true,"isSlideShow":0,"intIntervalSlideShow":10,"isReadOnly":false,"isDisabled":false}">
<span class="tab_title_span show" id="tab_title_span2">THISBUTTON</span><!--{"columns":"2","allowConfig":true,"allowClose":true,"fixedColumn":null,"eventCode":"null","pageNumber":2,"isPreset":false,"name":"THISBUTTON","boxWidth":"1220:209","autoFit":true,"isSlideShow":0,"intIntervalSlideShow":10,"isReadOnly":false,"isDisabled":false}--><input type="text" id="tab_title_input2" class="tab_title_input hide" maxlength="64">
</div>
<div class="tab_controls" id="tab_controls2">
<div class="tab_more_btn" id="tab_more_btn2"></div>
<div class="tab_options_btn" id="tab_options_btn2"></div>
</div>
<div class="tab_more_menu" id="tab_more_menu2">
<div class="tab_more_menu_unit" id="tab_more_menu_rename2">Rename</div>
<div class="tab_more_menu_unit" id="tab_more_menu_chg_layout2">Change Layout</div>
<div class="tab_close_btn tab_more_menu_unit" id="tab_close_btn2">Delete</div>
</div>
</div>
我尝试过以下方法:
clickme = browser.find_elements_by_id('tab_title_span2')
browser.execute_script("arguments[0].click();", clickme[0])
答案 0 :(得分:0)
它可能适用于动作链。
this_button = browser.find_element_by_id('tab_title_span2')
ActionChains(driver).move_to_element(this_button).click(this_button).perform()