Программа зависает при попадании в строку FindElement () в функции GetValue
class Program
{
static void Main(string[] args)
{
Uri huburl = new Uri("http://selenium-hub:4444/wd/hub");
DesiredCapabilities capabilities = DesiredCapabilities.Firefox();
capabilities.IsJavaScriptEnabled = true;
RemoteWebDriver myDriver = new RemoteWebDriver(huburl, capabilities);
myDriver.Navigate().GoToUrl("http://mycompany/main.asp");
CheckUserRegistered(myDriver);
}
public static void CheckUserRegistered(RemoteWebDriver oSeleniumWebDriverSession)
{
string sUserName = "test-01";
if (oSeleniumWebDriverSession.PageSource.ToLower().Contains("some text"))
{
oSeleniumWebDriverSession.FindElementByLinkText("Register Now").Click();
oSeleniumWebDriverSession.FindElementByName("fname").SendKeys(sUserName);
oSeleniumWebDriverSession.FindElementByName("lname").SendKeys(sUserName);
if (GetValue(oSeleniumWebDriverSession, By.Name("ReferenceIndicator")))
{
oSeleniumWebDriverSession.FindElementByName("ReferenceIndicator").SendKeys(sUserName);
}
oSeleniumWebDriverSession.FindElementByName("company").SendKeys(sUserName);
oSeleniumWebDriverSession.FindElementByName("postcode").SendKeys("mycompany");
oSeleniumWebDriverSession.FindElementByName("email").SendKeys(string.Format("{0}@mycompany.com", sUserName));
System.Console.WriteLine("Not Found");
System.Console.ReadKey();
oSeleniumWebDriverSession.FindElementByCssSelector("css=input[type=submit]").Click();
}
}
private static bool GetValue(RemoteWebDriver myDriver, By by)
{
try
{
//this is where it locks up.
myDriver.FindElement(by);
}
catch (NoSuchElementException Ex)
{
System.Console.WriteLine("Not Found");
System.Console.ReadKey();
return false;
}
return true;
}
}