Hello,
Some ISV Solutions contain externally hosted popup forms, or other UI elements that are missed by the Wrapper Generation process ClassGenerator.exe
The most common example being Credit card capture popup forms.
The solution to access these fields require you create your own Wrappers manually.
Below is an example Extension file that has the custom wrapper code inside of it
For selecting elements, if the field has an ID="firstName" you can simply put
FirstName = new Input("firstName", null, null, null);
otherwise you can use any other unique CSS attribute, such as label, text or any other attribute from the browser Inspection Element window.
You can look at more examples by looking at any other wrapper class for similar structure, but in their case auto-generated by ClassGenerator.exe
Then use it like any other extension inside your test.
HostedFormHandler Hosted = new HostedFormHandler();
HostedFormHandler.City.Type(“Montreal”);
HostedFormHandler.Add();
public class HostedFormHandler : Wrapper
{
public Input Name, CardNumber, CVV, BillingZip, Address, City;
public Button SendTokenBack1, SendTokenBack;
public HostedFormHandler()
{
Name = new Input("css=[aria-label='* Cardholder (name)']", "* Cardholder (name)", null, null);
CardNumber = new Input("css=[aria-label='* Card Number']", "* Card Number", null, null);
CVV = new Input("css=[aria-label='* CVV/CSC']", "* CVV/CSV", null, null);
BillingZip = new Input("css=[aria-label='* Billing Zip']", "* Billing Zip", null, null);
Address = new Input("css=[aria-label='* Billing Street Address']", "* Billing Street Address", null, null);
City = new Input("css=[aria-label='* Billing City']", "* Billing City", null, null);
SendTokenBack1 = new Button("css=button:textEqual('Create Card Token')", "Create Card Token", null);
}
public void Add()
{
Token.Type("ABC");
Token2.Type("5555 5555 5555 4444");
//Token3.Click();
new DefaultControl("css=:textEqual(\"* Expire Month\")", null, null, null).Click(); //click the dropdown for expire month
new DefaultControl("css=.q-item__label:textEqual(\"December\")", null, null, null).Click(); //select december fomr the li dropdown list
new DefaultControl("css=:textEqual(\"* Expire Year\")", null, null, null).Click();
new DefaultControl("css=.q-item__label:textEqual(\"2042\")", null, null, null).Click();
new DefaultControl("css=:textEqual(\"* Billing State\")", null, null, null).Click();
new DefaultControl("css=.q-item__label:textEqual(\"New York\")", null, null, null).Click();
Token5.Type("123");
Token6.Type("10011");
Token7.Type("156 10th Ave");
Token8.Type("New York");
Maximize();
SendTokenBack1.Click();
}
public void Maximize()
{
const string scriptMaximizePanel = "var elem = window.document.activePanel && window.document.activePanel.element.querySelector('.control-Maximize'); elem && elem.click();";
Browser.JavaScriptExecutor.ExecuteScript(scriptMaximizePanel);
Wait.WaitForCallbackToComplete();
Log.Screenshot();
}
public void Close()
{
const string scriptMaximizePanel = "var elem = window.document.activePanel && window.document.activePanel.element.querySelector('.control-Close'); elem && elem.click();";
Browser.JavaScriptExecutor.ExecuteScript(scriptMaximizePanel);
Wait.WaitForCallbackToComplete();
Log.Screenshot();
}
}