[英]Button's background color turns grey when mouse hovering on it C# Winforms
[英]C# Selenium - Unable to get background color of element mouse is hovering over
我正在用我的方法這樣做:
var firstCategoryTitle = pageTypeCategoryDiv.FindElement(By.ClassName("result.firstCategory")); // this is definitely selecting the correct element
Actions action = new Actions(Driver);
action.MoveToElement(firstCategoryTitle).Click().Build().Perform();
firstCategoryTitle.GetCssValue("background-color").Should().Be("rgba(0, 155, 212, 1)");
由於某種原因,即使當鼠標單擊該行元素時突出顯示該行元素,背景色也會變為藍色(如預期的那樣),但是一旦測試運行完成,它就會拋出一個錯誤,因為它找不到預期的顏色(預期的藍色),即使元素將突出顯示為藍色,也會找到白色而不是一致地找到白色。
任何幫助表示贊賞。
添加一個延遲,只是為了檢查在實際顏色更改之前是否未執行GetCssValue語句。
Actions action = new Actions(Driver);
action.MoveToElement(firstCategoryTitle).Click().Build().Perform();
Thread.Sleep(5000);
firstCategoryTitle.GetCssValue("background-color").Should().Be("rgba(0, 155, 212, 1)");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.