Closed mcdonaldp2 closed 6 years ago
Thanks @mcdonaldp2 - we're reviewing this scenario and will try to get back with a means of accomplishing this.
@mcdonaldp2 - I have tested this internally and the code below should help with your scenario:
It looks like you had most of it, but I suspect the XPath ID is incorrect. XPath is case sensitive so be wary of that when reviewing the name of the ID fields. In my example, the dropdown field only had true/false inputs so the SelectByText command would be the name of an option value.
I included an example for basic text fields as well. Please give this a try and let us know if you are still encountering any issues.
//Switch to the WebResource frame
xrmBrowser.Driver.SwitchTo().Frame("WebResource_Example");
//Option/Dropdown field example
SelectElement exampleoption = new SelectElement(xrmBrowser.Driver.FindElement(By.XPath("//*[@id=\"Select1\"]")));
exampleoption.SelectByText("false");
//Text field input example
IWebElement exampletext = xrmBrowser.Driver.FindElement(By.XPath("//*[@id=\"Text1\"]"));
exampletext.SendKeys("Hello World.");
Thanks, Tyler
@TYLEROL On this line
xrmBrowser.Driver.SwitchTo().Frame("WebResource_NewAccountType");
I am getting no such frame exception. This webresource is embedded on the form of account and looks like the following:
<html>
<head>
<style type="text/css">P { margin: 0; }</style>
<script type="text/javascript" src="Account"></script>
</head>
<body style="word-wrap: break-word;">
<p>What Type of account would you like to create?</p>
<select id="accounttypeid">
<option value="Customer">Customer</option>
<option value="Intermediary">Intermediary</option>
<option value="Other">Other</option>
</select> <br>
<button onclick="accountJs.setNewAccountType(document.getElementById('accounttypeid').value)">Submit</button>
</body>
</html>
Is there a restructuring that needs to be done to the web resource to get this to work?
@mcdonaldp2 - Are you using the WebResource control type when you designed the Account form? If so, this control embeds itself as an iframe. You should be able to verify the iframe id by using the Inspect Element tool within your browser dev tools . My tags look like the following using the WebResource control and an HTML web resource uploaded to my Dynamics org:
<iframe frameborder="0" id="WebResource_Example" onload="if(!IsNull(Mscrm.InlineIFrameControlView)) Mscrm.InlineIFrameControlView.loadHandler("WebResource_Example")" class="ms-crm-Custom-Read" tabindex="0" url="/%7B636564928990003292%7D/WebResources/mss_/Example.htm" src="/_static/blank.htm" iswebresource="True" scrolling="auto" style="visibility: visible; height: 144px; width: 719px;"></iframe>
Does the id in your scenario list WebResource_NewAccountType or something else? The naming of the ID and the declaration within the test in this scenario is also Case Sensitive.
@TYLEROL that is correct, I have copied the id directly from the tag when inspecting the element in chrome. Just fixed my comment above, is there any restructuring i need to do on the webresource itself?
Here is my iframe tag:
<iframe frameborder="0" id="WebResource_NewAccountType" onload="if(!IsNull(Mscrm.InlineIFrameControlView)) Mscrm.InlineIFrameControlView.loadHandler("WebResource_NewAccountType")" class="ms-crm-Custom-Read" tabindex="0" url="/%7B636568010430001161%7D/WebResources/ca_GetAccountType" src="/_static/blank.htm" iswebresource="True" scrolling="auto" style="visibility: visible; height: 216px; width: 969px;"></iframe>
Thanks @mcdonaldp2 - I implemented your WebResource scenario in two different organizations, v8.2 and v9, and both worked successfully. You should not have to restructure anything on your web resource.
Does the WebResource control reside within a tab that is expanded by default and/or a section that is visible by default?
I've included a screenshot example of my placement at the top of the form, and my test below. If you still encounter problems, can you provide me the following?:
Code Sample
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Security;
using Microsoft.Dynamics365.UIAutomation.Api;
using Microsoft.Dynamics365.UIAutomation.Browser;
using OpenQA.Selenium.Support.UI;
using OpenQA.Selenium;
using System.Collections.Generic;
namespace Microsoft.Dynamics365.UIAutomation.Sample
{
[TestClass]
public class UpdateAccount
{
private readonly SecureString _username = System.Configuration.ConfigurationManager.AppSettings["OnlineUsername"].ToSecureString();
private readonly SecureString _password = System.Configuration.ConfigurationManager.AppSettings["OnlinePassword"].ToSecureString();
private readonly Uri _xrmUri = new Uri(System.Configuration.ConfigurationManager.AppSettings["OnlineCrmUrl"].ToString());
[TestMethod]
public void TestUpdateAccount()
{
using (var xrmBrowser = new XrmBrowser(TestSettings.Options))
{
xrmBrowser.LoginPage.Login(_xrmUri, _username, _password);
xrmBrowser.ThinkTime(500);
xrmBrowser.Dialogs.CloseWarningDialog();
xrmBrowser.GuidedHelp.CloseGuidedHelp();
xrmBrowser.ThinkTime(500);
xrmBrowser.Navigation.OpenSubArea("Sales", "Accounts");
xrmBrowser.ThinkTime(2000);
xrmBrowser.Grid.SwitchView("Active Accounts");
xrmBrowser.ThinkTime(1000);
//Open Primary Entity record
xrmBrowser.Grid.OpenRecord(0);
xrmBrowser.ThinkTime(3000);
// Issue 99
//Switch to the WebResource frame
xrmBrowser.Driver.SwitchTo().Frame("WebResource_NewAccountType");
//Option/Dropdown field example
SelectElement exampleoption = new SelectElement(xrmBrowser.Driver.FindElement(By.XPath("//*[@id=\"accounttypeid\"]")));
exampleoption.SelectByText("Other");
xrmBrowser.ThinkTime(3000);
}
}
}
}
@mcdonaldp2 - Were you able to get this scenario working on your end? If not, please re-open this issue for further investigation.
Is this functionality going to be added for UCI/xrmApp (v.9.0.2)? @TYLEROL
Hi Tyler Olson,
I am also facing same issue with web resource.
Thanks, Chetan
On some of my entity forms their are custom html web resources that have forms. I have tried switching the frame to the iframe's id like so but no luck: xrmBrowser.Driver.SwitchTo().Frame("WebResource_NewAccountType");
I have also tried just selecting elements from the custom form within the webresource but haven't had luck doing that either: SelectElement dropdown = new SelectElement(xrmBrowser.Driver.FindElement(By.XPath("//*[@id=\"accounttypeid\"]")));
What is the proper way to do this in easyrepro?