WaitForElement(String Zone, String Element, int Index, int Timeout)
|
|
|
|
|
|
|
Sets sleep until element is identified.
Zone: Select Zone
Element: Query to identify the objects/Name of the element on the object repository.
Index: Element Order (the number of times the element appears more than once). Index=0 refers to the first appearance of the element; Index=1 refers to the second appearance of the element, etc.
Timeout: Waiting Timeout in milliseconds.
Scenario: On the following scenario we will try to create an account on gmail.com.
We will see that it might take time to load the page, so by adding a step of waitForElement the test stability is improved.
Step 1: Launch google.com using the chrome browser.
Step 2: Click the create an account button.
Step 3: Fill in name on Name text field.
Test:
Web page was not fully loaded. Element was not identified before the click command's timout which resulted on the test failing.
How to resolve this issue
We will use the WaitForElement command. Silk Mobile will wait for the element and it will not move to the next step.
client.waitForElement("WEB", "id=FirstName", 0, 10000)client.WaitForElement("WEB", "id=FirstName", 0, 10000)client.WaitForElement ("WEB", "id=FirstName", 0, 10000)self.client.waitForElement("WEB", "id=FirstName", 0, 10000) $client->waitForElement("WEB", "id=FirstName", 0, 10000)