Collections:
Test Script Coding with Web Page Objects
How to write test script code with Web page objects? I have captured enough objects with Object Spy.
✍: FYIcenter.com
You can follow these suggestions when writing test script code
with Web page objects:
1. Use the following code to access a specific browser object:
objBrowser = Browser(browser_name)
'For example:
objBrowser = Browser("Browser")
2. Use the following code to access a specific Web page object under a browser object:
objPage = objBrowser.Page(page_name)
'For example:
objPage = objBrowser.Page("FYI Center for SQA")
3. Use the following code to access a specific Web element object under a Web page object based on element types:
'For <input> element type: objElement = objPage.WebEdit(element_name) 'For <img> element type: objElement = objPage.Image(element_name) 'For <a> element type: objElement = objPage.Link(element_name)
4. Use action methods on objects to interact with objects:
'Use Set() method to set value to a <input> element
objPage.WebEdit("Q").Set("JMeter")
'Use click() method to trigger the browser to follow a hyperlink
objPage.Link("Submit").click
'Use click() method can also be used on clickable images
objPage.Image("Submit").click
Here is a good example of test script code using Web page objects captured in previous tutorials.
SystemUtil.Run "chrome.exe", "http://sqa.fyicenter.com"
wait(2)
Browser("Browser").Page("FYI Center for SQA").WebEdit("Q").Set("JMeter")
Browser("Browser").Page("FYI Center for SQA").Link("Submit").click
SystemUtil.CloseProcessByName("chrome.exe")
If you run the above script, it will start Chrome with the test Web page loaded. Then it will enter "JMeter" in the search box and click the Submit image button.
2018-05-08, 2472🔥, 0💬
Popular Posts:
How to generate test phone numbers for US and Canada? Test phone numbers are frequently needed in te...
How to convert a date and time to a standard format? Date and time can be displayed in a number of s...
How to validate Mod 10 (Luhn Algorithm) checksum? In order to help your programming or testing tasks...
How to find out my browser's identification information? To help you to see your browser identificat...
How to perform UUDecode (Unix-to-Unix Decode)? UUEncode is Unix-to-Unix encoding used on Unix system...