Im only been working with Java before but need to set up some tests in C#.
In a login test I like to have a wait method waiting for the login cookie to be set.
In Java I can do something like this, but not able to create the same in C#, can anyone help me convert this code to C#?
public void getTokenCookie(){
try {
wait.until(
new ExpectedCondition<Cookie>() {
@Override
public Cookie apply(WebDriver webDriver) {
Cookie tokenCookie = driver.manage().getCookieNamed("nameOfCookie");
if (tokenCookie != null) {
System.out.println("\nToken Cookie added: " + tokenCookie);
return tokenCookie;
} else {
System.out.println("waiting for cookie..");
return null;
}
}
}
);
} catch (Exception e){
System.out.println(e.getMessage());
fail("Failed to login, no cookie set");
}
}