我需要验证div的背景颜色的值.这是HTML:
<div id="outercontainer" align="left">
Run Code Online (Sandbox Code Playgroud)
有关背景颜色的信息在文件style.css中定义,如下所示:
#outercontainer {
background-color: #EAEAEA;
margin-left: auto;
margin-right: auto;
opacity: 1;
width: 1000px;
z-index: 2;
}
Run Code Online (Sandbox Code Playgroud)
我尝试使用selenium.getattribute命令获取bgcolor的值,但是selenium返回了以下错误消息:
错误:无法找到元素属性:css =#oute rcontainer @ background-color on session bc60eb07f15e4e63986634fb59bf58a1
作为结果.这部分代码:
try
{
string atr_str = selenium.GetAttribute("css=#outercontainer@background-color");
Console.WriteLine(atr_str);
}
catch (SeleniumException)
{
Console.WriteLine("Color value was not got.");
}
Run Code Online (Sandbox Code Playgroud)
事实上,我尝试了不同类型的定位器的不同方式,但没有任何帮助我.你有什么建议吗?