【问题标题】:Element visible for hover but invisible for click元素悬停可见但点击不可见
【发布时间】:2018-02-08 11:55:33
【问题描述】:

我正在使用 Selenide 为结帐页面编写自动化脚本。页面上有一个元素表示条款和条件的复选框。我试图点击它但没有成功。但是,悬停命令可以正常工作而没有任何错误。因此,单击时不可见,但悬停时可见。怎么点击?

<input type="checkbox" name="order[accept_terms_and_conditions]" 
id="order_accept_terms_and_conditions" value="1" aria-label="Accept 
terms and conditions">

第一个元素选择器:

private By termsCheckbox = By.xpath("//*[@id=\"bottom_form\"]/fieldset/ol/li/label/input");

有动作的方法

public void clickTermsCheckbox(){
$(termsCheckbox).hover().click();
}

错误

Element should be visible {By.xpath: //*[@id="bottom_form"]/fieldset/ol/li/label/input}

【问题讨论】:

标签: java selenium-webdriver qa selenide


【解决方案1】:

尝试点击父元素:

$(termsCheckbox).parent().click()

【讨论】:

    猜你喜欢
    • 2020-11-29
    • 2018-08-17
    • 1970-01-01
    • 2013-05-25
    • 2012-07-06
    • 1970-01-01
    • 1970-01-01
    • 2011-08-04
    • 1970-01-01
    相关资源
    最近更新 更多