Selenium Webdriver Chrome V80 iframe names are empty even the DOM said they have names

163 Views Asked by At

I am using selenium with C#. The browser is Chrome version 80. The website I am using is Microsoft Dynamics CRM 2013 v8.1. I am trying to close a dialog box which pops up when a radio button is clicked. The problem I am having is that I can't find the button to click OK and confirm the dialog to close it.

I have tried going into chrome and using copy full XPath. I have also used the ID for the button. These methods threw an error saying it couldn't find that element. I figured I need to change the focus of the iframe. When I looked at the page threw the google chrome inspector the iframes have names. I changed to the iframe I needed but selenium still couldn't find the iframe. I have tried grabbing the iframe and button by id but had no luck.

I will include my test code below.

In summary I think I need to change the iframe focus to grab the button I am looking for but none of the iframes have names which they do in the DOM. Any thoughts or suggestions.

 public void TestCase()
        {
            using (var xrmBrowser = new Api.Browser(TestSettings.Options))
            {
                xrmBrowser.LoginPage.Login(_xrmUri, _username, _password);
                xrmBrowser.Navigation.OpenSubArea("Client Services", "Cases");
                xrmBrowser.Grid.SwitchView("Active Cases");
                xrmBrowser.CommandBar.ClickCommand("New Case");
                xrmBrowser.ThinkTime(4000);

                // Populate Form
                xrmBrowser.Entity.SetValue("title", "Test API Case");
                xrmBrowser.Entity.SetValue("casetypecode", "Request");
                xrmBrowser.Entity.SetValue("caseorigincode", "Phone");
                xrmBrowser.Entity.SelectLookup("customerid", 0);
                xrmBrowser.Entity.SetValue("new_anonymousclient", true);
                xrmBrowser.ThinkTime(100);
                // xrmBrowser.Driver.SwitchTo().Frame(2);
                // xrmBrowser.Driver.FindElement(By.XPath("/html/body/div/div[2]/button[1]")).Click();
                var iframes = xrmBrowser.Driver.FindElements(By.TagName("iframe"));
                var iframeName = "";
                foreach (var iframe in iframes)
                {
                    // My attempt at getting iframe names. These are all blank but contain 4 iframes.
                    iframeName = iframe.GetAttribute("name");
                }

                xrmBrowser.ThinkTime(100);
                // LABEL btnOK

                xrmBrowser.CommandBar.ClickCommand("Save");
                xrmBrowser.ThinkTime(1000);


            }
        }

PS> I am using EasyRepro but had no success in closing this dialog that popped up. In the chrome inspector I can access the button and click it through JS.

0

There are 0 best solutions below