-
Notifications
You must be signed in to change notification settings - Fork 1
Home
sharonlambson edited this page May 16, 2018
·
42 revisions
// defining Page Elements
PageElement inputElement = new PageElement("Input Elements", FindBy.tagName("input"));
// getting a list of Page Elements
List<PageElement> inputElementList = browserWrapper.getPageElements(inputElement);
// defining Page Elements
PageElement inputQueryBox = new PageElement("Google Query Box", FindBy.name("q"));
PageElement buttonGoogleSearch = new PageElement("Google Search Button", FindBy.value("Google Search"));
// interacting with Page Elements
browserWrapper.type(inputQueryBox, "searching for stuff");
browserWrapper.click(buttonGoogleSearch);
PageElement filesTable = new PageElement("Files table", FindBy.className("files"));
PageElement inputElements = new PageElement("Examples Link", In.ParentElement(filesTable), FindBy.hrefContains("example"));
PageElement inputElements = new PageElement("Examples Link", In.ParentElement(FindBy.className("files")), FindBy.hrefContains("example"));
PageElement informationLink = new PageElement("FrameID", In.Frame("myDemoFrameID"), FindBy.name("myElement"));
PageElement demoIframe = new PageElement("Demo iFrame", FindBy.name("myDemoFrame"));
PageElement forecastLink = new PageElement("Forecast Link", In.Frame(demoIframe), FindBy.attributeValue("data-qa", "forecast-link"));
PageElement imageAttributeValue = new PageElement("Image element by attribute value", FindBy.attributeValue("data-qa", "slick-logo"));
PageElement labelByText = new PageElement("Element by text", FindBy.text("Some Text");
Given this html snippet:
<div>
<input type="checkbox">
<label>Need to click\</label>
</div>
PageElement label = new PageElement(FindBy.text("Need to click"));
PageElement checkBox1 = new PageElement("Checkbox", Relative.FollowedBySibling(new PageElement(label), "input");
This will allow you to interact with the checkbox element that is otherwise not uniquely identifiable.
Given this html snippet:
<div>
<label>Need to click\</label>
<input type="checkbox">
</div>
PageElement label = new PageElement(FindBy.text("Need to click"));
PageElement checkBox1 = new PageElement("Checkbox", Relative.PrecededBySibling(label), "input");
This will allow you to interact with the checkbox element that is otherwise not uniquely identifiable.
Given this html snippet:
<a>
<label>Need to click\</label>
</a>
PageElement label = new PageElement(FindBy.text("Need to click"));
PageElement link = new PageElement("Link", Relative.Descendent(label, "a");`
This will allow you to interact with the anchor element that is otherwise not uniquely identifiable.