简体   繁体   English

元素对于悬停可见,但对于单击不可见

[英]Element visible for hover but invisible for click

I'm writing an automation script for a checkout page with Selenide. 我正在使用Selenide为结帐页面编写自动化脚本。 There's an element on a page that represents checkbox for terms and conditions. 页面上有一个元素,表示条款和条件的复选框。 I've tried to click it but no success. 我试图单击它,但没有成功。 However, hover command works properly without any errors. 但是,悬停命令可以正常工作,没有任何错误。 So it is not visible for clicking but visible for hovering. 因此单击时不可见,但悬停时可见。 How can it be clicked? 如何点击?

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

Th element selector: 元素选择器:

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

The method with action 采取行动的方法

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

Error 错误

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

尝试单击父元素:

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

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM