Я пытаюсь нажать кнопку входа (Đăng nhập), чтобы открыть окно входа, но этого не добиться.Почему модальное окно не появляется при нажатии selenium
Номер для входа в систему просто не отображается.
Селен, WebDriver являются все последние версии
using (IWebDriver driver = new ChromeDriver())
{
driver.Navigate().GoToUrl("http://sinhvienit.net/forum/");
// driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(30));
// driver.FindElement(By.XPath("//a[@href='#loginform']//span")).Click();
// driver.FindElement(By.XPath("//a[@href='#loginform']")).Click();
var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));
wait.Until(ExpectedConditions.ElementExists(By.XPath("//a[@href='#loginform']"))).Click();
wait.Until(ExpectedConditions.ElementExists(By.XPath("//a[@href='#loginform']//span"))).Click();
wait.Until(ExpectedConditions.ElementExists(By.Id("navbar_username")));
wait.Until(ExpectedConditions.ElementExists(By.Id("navbar_password")));
// var loginBox= wait.Until(ElementIsClickable(By.Id("loginform"))); >> fail
driver.Scripts().ExecuteScript("document.getElementById('navbar_username').style.display='inline';");
driver.Scripts().ExecuteScript("document.getElementById('navbar_password').style.display='inline';");
Console.ReadKey();
}
C# расширение:
public static IJavaScriptExecutor Scripts(this IWebDriver driver)
{
return (IJavaScriptExecutor)driver;
}
'driver.FindElement (By.XPath (" // a [@href = '# loginform'] ")). Click();' должен работать. Что делать, если вы сначала будете ждать его: 'wait.Until (ExpectedConditions.ElementExists (By.XPath (" // a [@href = '# loginform'] ")). Click();'? – alecxe
спасибо, но это doesn не работает, странно. Редко это проявляется, просто не знаю, почему –
что вы пробуете в другом браузере? – alecxe