2

私はSeleniumを使って統合テストを行っています。テストの一部はInternetExplorerWebDriverを使用すると、MicrosoftのAzure Active DirectoryのusesSeleniumがAzure Active Directoryログイン用のEdge webdriverをテストするときに要素が不明確になる

テストに合格し、ログオンプロセスであるが、エラーとEdgeWebDriverで失敗します。

Element is obscured

コードの関連部分:

var wait = new WebDriverWait(webDriver, TimeSpan.FromSeconds(10)); 
webDriver.Url = Settings.UrlHome(); 

var signInElement = webDriver.FindElement(By.Id("SignInLink")); 
signInElement.Click();  

wait.Until(ExpectedConditions.ElementToBeClickable(By.Id("my_login_name"))); 
var loginLogoMicrosoft = webDriver.FindElement(By.Id("my_login_name")); 

loginLogoMicrosoft.Click(); 

最後のClick()を実行するとエラーが発生します。私は他のいくつかの要素を試しましたが、どれも働いていません。また、 'inspect element'を使用して、コードを実装するときにクリックを受け取る要素がこのエラーを受け取るかどうかを判断します。

Microsoft Azure Active DirectoryのログオンプロセスをSeleniumテストの一部にするにはどうすればよいですか?

同じ種類の問題がhereです。

+0

あなたのリンクによれば、それはEdgeDriverで確認されたバグです。それを待って... – FDM

答えて

1

次のコードを使用してAzure ADログインフォームを記入します。警告は、ユーザー名フィールドを入力すると、バックグラウンドでいくつかのajax操作が行われるまで、「サインイン」ボタンが無効になることです。そのトリックは、このクラスがないページにサインインボタンがあるまで待つことです。

private void SubmitLoginForm() 
{ 
    var useAnotherAccount = Driver.FindElements(By.ClassName("use_another_account")).FirstOrDefault(); 

    if (useAnotherAccount != null) 
    { 
     useAnotherAccount.Click(); 
    } 

    var loginInput = Driver.FindElements(By.Id(Site.Login.UserNameInput)).FirstOrDefault(); 

    if (loginInput != null) 
    { 
     loginInput.SendKeys(TestingData.UserName); 
     loginInput.SendKeys(Keys.Tab); 
    } 

    var passwordInput = Driver.FindElements(By.Id(Site.Login.PasswordInput)).FirstOrDefault(); 

    if (passwordInput != null) 
    { 
     passwordInput.Clear(); 
     passwordInput.SendKeys(TestingData.PassWord); 
     passwordInput.SendKeys(Keys.Enter); 
    } 

    var wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(5)); 
    wait.Until(f => f.FindElement(By.CssSelector("#cred_sign_in_button:not(.disabled_button"))); 

    var loginButton = Driver.FindElements(By.Id(Site.Login.SigninButton)).FirstOrDefault(); 

    if (loginButton != null) 
    { 
     loginButton.Click(); 
     return; 
    } 

    throw new InvalidOperationException("Could not click the login button"); 
} 
+0

この質問に答える主な2つの行は、var wait = new ...と待ちます。 – user890332

関連する問題