我需要在一个元素打开和关闭时识别它的两种颜色;例如,当它打开时它的 rgb(40, 170, 228) 和关闭 rgb(101, 113, 151) 时。我正在使用 Iwebdriver,因此受限于它带来的方法。
我尝试不成功 string color = IWebElement.GetCssValue("background-color");
来自另一个问题,但是,由于 GetCSSValue 不存在,我得到一个错误
iWebdriver Does Not Contain A Definition For GetCssValue
最佳答案
以下作品—— 将以下内容添加到您的 POM:
public IWebElement BranchToggleOn { get { return driver.FindElement(By.XPath("/html/body/div[1]/div/div/div/div[2]/div[2]/div/div/div/div/div/table/thead/tr/th[3]/div/label/span")); } }
然后在你的测试中:
string attValue = HomePage.BranchToggleOn.GetCssValue("rgb 255, 255, 255");
关于c# - 我如何找到元素颜色;切换时我需要检查的元素会更改颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58519938/