带有样式属性的元素的Css选择器 [英] Css selector for elements with style attribute

查看:129
本文介绍了带有样式属性的元素的Css选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有以下样式的元素

I have an element with the following styles

<ul class="textboxlist-bits" style="background-color: transparent;">

现在我想根据style属性选择元素。

Now I want to select the element based on the style attribute.

css选择器 ul [style =background-color:transparent;] 在那里不工作。

The css selector ul [style="background-color: transparent;"] does not work there.

建议一个合适的选择器来识别这样的元素。

Kindly suggest an appropriate selector to identify such element.

推荐答案

一个可能的解决方案是选择所有元素匹配类名,那么第一个具有正确样式属性的那些。你没有说测试是用哪种语言写的,但C#中的例子是:

A possible solution is to select all elements with matching class name, then the first of those with the correct style attribute. You haven't said which language the test is written in, but an example in C# would be:


IWebElement element = driver .FindElements(By.CssSelector(ul.textboxlist-bits))。首先(e => e.GetAttribute(style)。Contains(background-color:transparent;));

这篇关于带有样式属性的元素的Css选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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