Working with Web Elements
To test a web element, you have to create a new instance of such control.
For example, to click the ‘Text’ hyperlink in this figure you have to create first an instance of this element in Maveryx.
You can represent the Text hyperlink as a new instance of the class GuiHyperlink by giving its identifier (the anchor “Text”).
The identifier of a Web Element could be its attribute ‘id’ or ‘title’ or ‘name’ or the property ‘innerText’. You can also use the attributes ‘class’, ‘href’, ‘alt’, etc…
GuiHyperlink hLink = new GuiHyperlink ("Text");
hLink.click();
Or, you can represent the Text hyperlink as a new instance of the class GuiHtmlElement by giving its identifier (the anchor “Text“) and its role/type.
The role of a Web Element could be its html ‘tag’ or its attribute ‘type’ or ‘role’.
GuiHyperlink hLink = new GuiHyperlink ("Text", AccessibleRoleMaveryx.WEB_HYPERLINK);
hLink.click();
The class AccessibleRoleMaveryx contains all roles/types. The ones with the prefix ‘WEB_’ are specifically for web elements.
The class GuiHtmlElement allows to retrieve all attributes and properties of the web element to test.
For example, to verify the URL of the page the link goes to:
GuiHyperlink hLink = new GuiHyperlink ("Text");
//check the href attribute value
assertEquals("#text", hLink.getAttributeValue( "href" ));
Or to verify the property ‘innerHTML’:
GuiHyperlink hLink = new GuiHyperlink ("Text");
//check the innerHTML property value
assertEquals("#text", textField.getPropertyValue( "innerHTML"));
To manage the web browser, you can use the GuiBrowser class.
For example:
GuiBrowser b = new GuiBrowser();
b.maximize(); //maximize the browser window
b.navigateTo("www.maveryx.com"); //navigate to the specified URL