When my button is clicked, the ng-hide
directive will turn a hidden div to be visible on page. I am using Seleno
to write UI test for an Angular application.
I have checked the display
css value on that element:
var cssValue = SelectById(elementId).GetCssValue("display");
This cssValue
always returns a none
.
Also checked is the class
attribute.
var cls = SelectById(elementId).GetAttribute("class");
I am expecting ng-hide
should be removed from the classes of this element.
return !SelectById(elementId).GetAttribute("class").Contains("ng-hide");
But every time the class
still contains ng-hide
!
In case someone may ask, here is my SelectById
. Just to return a Web Element on the Selenium Page Object.
protected IWebElement SelectById(string id)
{
return Find.Element(By.Id(id));
}
As mentioned in the answer section, I probably did not wait out the class update by Angular in a correct way. What I did is just let the Thread
Sleep
a while.
public static void Pause(int durationInMilisecond = 2000)
{
if (SelenoSettings.EnablePausing)
Thread.Sleep(durationInMilisecond);
}
Anyone can give me some advice? Thanks.