不允许复合类名 - Selenium Java [英] Compound class names not permitted - Selenium Java

查看:30
本文介绍了不允许复合类名 - Selenium Java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下按钮可以定位.它是一个蚂蚁控制器.

I have following button to locate. It is an ant controller.

<li class="ant-picker-ok"><button type="button" class="ant-btn ant-btn-primary ant-btn-sm"><span>Ok</span></button></li>

它位于数据输入表单中,其 XPath 更改取决于我们在表单顶部所做的选择.所以XPath不能使用.然后我尝试了 CSS 选择器,它也不支持.

this is located in data entry form and its XPath change depend upon the selections that we made in top part of the form. So XPath cannot use. then i tried CSS selector and it also not support.

最后我使用类名作为定位策略并使用移动到元素.

Finally I used class name as location strategy and use move to element.

@FindBy(className = "ant-picker-ok")
public WebElement shiftEndOkBtn;

代码成功执行到下一行.

code successfully execute upto below line.

new Actions(driver).moveToElement(shiftEndOkBtn).perform(); 

点击部分我们不起作用并且抛出元素不可见.但是元素是可见的

clicking part us not working and throws element is not visible. But element is visible

shiftEndOkBtn.click();

这是一个蚂蚁时间选择器(

This is a ant time picker(https://ant.design/components/time-picker/)Any idea to solve this issue?

推荐答案

您单击的是li"元素,而不是按钮.尝试通过 XPath 找到它:

You are clicking the 'li' element, not the button. Try find it by XPath:

//li[@class = 'ant-picker-ok']/button

这篇关于不允许复合类名 - Selenium Java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆