Note: Updated response based on new information.
After running the code snippet below, the following sequence of events occurs:
- Selenium inputs user data
- I manually refresh the page because login credentials are not available for testing
- Selenium inputs user data again
(the variable W represents a previously defined WebDriverWait
.)
driver.Navigate().GoToUrl("https://www.irctc.co.in/eticketing/loginHome.jsf");
// Attempt to loop until reaching the relevant page
do
{
try
{
IWebElement username = w.Until(ExpectedConditions.ElementIsVisible(By.Id("usernameId")));
IWebElement password = driver.FindElement(By.Name("j_password"));
if (String.IsNullOrEmpty(username.GetAttribute("value")))
{
username.SendKeys("a");
password.SendKeys("b");
}
}
catch (Exception)
{
// Page is reloading, wait for another iteration
}
} while (!String.Equals(driver.Url, "put url after login here"));