简体   繁体   English

如何在没有文本的情况下单击带有角色按钮的 div? 使用 Python Selenium

[英]How i can click on a div with role button without text? Using Python Selenium

This is the html code exemple:这是 html 代码示例:

<div aria-label="Continue" class="my-class" data-visualcompletion="ignore"></div>
    <div class="div1-class">
        <div class="div1-class2">
            <span class="area-span" dir="auto">
                <span class="text-span">Continue</span>
            </span>
        </div>
    </div>
    <div class="div2-class" data-visualcompletion="ignore"></div>

I'm trying:我正在努力:

continue = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.CLASS_NAME, 'my-class')) )
continue.click()

but it doesn't work in any of the ways I tried.但它在我尝试过的任何方式中都不起作用。

You should check the xpaths in the browser console.您应该在浏览器控制台中检查 xpaths。 And try doing this?并尝试这样做?

driver.findElement(By.xpath("//div[contains(@class,'my-class')]"));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用硒python动态单击按钮或div标签直到其从页面消失? - How can I click button or div tag dynamically until it disappear from page using selenium python? 如何使用Selenium和python单击网页上的所有“ role = button” - How to Click on all “role=button” on a webpage using selenium and python 我如何使用 Selenium lib 单击文本下方的按钮。 在 Python - How i can click a button below a text using Selenium lib. in Python 如何使用selenium python单击文本按钮 - How to click on the text button using selenium python 如何使用 python 3.8 selenium 单击 href 按钮? - How can I click a href button using python 3.8 selenium? Python Selenium 如何单击此按钮 - Python Selenium How can I click this button 如何使用 Selenium 和 Python 在不同的 div 中单击第二个 href 文本 - How to click second href text in different div using Selenium and Python 如何使用 Python Selenium 单击没有 ID 的按钮? - How to click on a button without ID using Python Selenium? 如何使用 Selenium 和 Python 单击带有文本的按钮向我发送推送? - How to click the button with text Send Me a Push using Selenium and Python? 如何使用 Selenium 和 Python 单击带有文本的按钮显示更多结果? - How to click on button with text Show more results using Selenium and Python?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM