MSD CRM上的Selenium - NavBarOverlay会阻止点击

时间:2016-11-28 08:53:29

标签: selenium dynamics-crm dynamics-crm-2016

我尝试在CRM 2016 SP1中使用Selenium C#进行自动UI测试。

尝试点击ContentIFrame中的元素时,我经常会遇到异常

Imports Microsoft.Office.Interop

Public Class Form1


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim wd1 As Word.Application
    Dim wd1Doc As Word.Document
    wd1 = New Word.Application
    wd1.Visible = True

    wd1Doc = wd1.Documents.Add("C:\Users\DELL\Desktop\activity6\profile.dotx")

    With wd1Doc
        .FormFields("w_name").Range = TextBox1.Text
        .FormFields("w_age").Range = TextBox2.Text
    End With
    wd1 = Nothing
    wd1Doc = Nothing

End Sub
End Class

这是由于仍然会覆盖的navBarOverlay。

我尝试了很多选择:

  1. Element is not clickable at point (743, 496). Other element would receive the click: <div class="navBarOverlay" id="navBarOverlay" style="display: block;"></div>
  2. By navBarOverlay = By.Id("navBarOverlay"); wait.Until(ExpectedConditions.InvisibilityOfElementLocated(navBarOverlay));
  3. 在找到elementToClick 之前
  4. wait.Until(ExpectedConditions.ElementToBeClickable(elementToClick); 在找到elementToClick
  5. 之前
  6. Thread.Sleep(3000);

    然而,没有成功.. 我该怎么办呢?

1 个答案:

答案 0 :(得分:1)

我能够解决这个问题。 我用js注射隐藏这个div

var navbar = WebDriverManager.Driver.FindElement(By.Id("navBarOverlay"));
WebDriverManager.Driver.ExecuteJavaScript("arguments[0].setAttribute('style', 'display: none')", navbar);