Reputation: 73
<a href="eventLog.cgi?command=0" target="content" class="Menu_titleFont">View Event Log</a>
How to click the "view event log"
in selenium
?
I have tried
By.CssSelector("a[href^='eventLog.cgi?command=0']")
but "NoSuchElementException was unhandled"
error occured.
Upvotes: 2
Views: 184
Reputation: 52665
You can try to wait until element is present in DOM
as below:
WebDriverWait wait = new WebDriverWait(webDriver, TimeSpan.FromSeconds(10));
wait.Until(ExpectedConditions.ElementExists(By.CssSelector("a[href='eventLog.cgi?command=0']")));
or
WebDriverWait wait = new WebDriverWait(webDriver, TimeSpan.FromSeconds(10));
wait.Until(ExpectedConditions.ElementExists(By.LinkText("View Event Log")));
If your element located inside iframe
, you might need to use
webDriver.SwitchTo().Frame("menu");
before searching for element
Upvotes: 2