gpt4 book ai didi

java - 如何验证 selenium webdriver 中的文本颜色?

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:03:54 26 4
gpt4 key购买 nike

我有一个网络应用程序。

使用 selenium webdriver 编写的自动化脚本。

我在选择一些文本时写了一些颜色代码。

Now I want to check that color is present or not.

如何验证 selenium webdriver 脚本中的颜色代码?

最佳答案

绿色哈希码#RRGGBB : #008000//测试数据,可以用任何特定颜色替换

可以试试下面的代码:

String colorString = driver.findElement(By.id("foo")).getAttribute("class");
String[] arrColor = colorString .split("#");
assertTrue(arrColor[1].equals("008000"));

关于java - 如何验证 selenium webdriver 中的文本颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24669787/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com