In this article we will see the functions used for getting a web element from a web application using Robotium while doing testing.
We need to initiate the Solo object. After initiation, we will uses solo to get those.
For Single web element :
Solo object have a function named solo.getWebElement(), where we use two parameter to get element. First parameter is for element finder(By object) and 2nd one is the index(nth found), So
-The function returns a web element
-We need to specify By object( the object finder)
-We need to specify index. (Zero based integer index and in here 0 means found 1)
-To select a web element by its class name(Actually it is the type name defines what type of web element that is, like button, text box etc)
solo.getWebElement(By.className("Textbox"),0);
-To select a web element by its css selector
solo.getWebElement(By.cssSelector("CSSAsString"),0);
-To select a web element by its ID
solo.getWebElement(By.id("idAsString"), 0);
-To select a web element by its Name
solo.getWebElement(By.name("NameAsString"), 0);
-To select a web element by itsTag Name
solo.getWebElement(By.tagName("tagNameAsString"), 0);
-To select a web element by its text content
solo.getWebElement(By.textContent("contentAsString"), 0);
-To select a web element by its Xpath
solo.getWebElement(By.xpath("xpathAsString"), 0);
For Multiple web element :
There are two function,
1. solo.getCurrentWebElements(By.[--by xpath or above items--])
This is just multiple version of previous single web element finding
2. solo.getCurrentWebElements();
For both cases they provide an array list of WebElements displayed in the active WebView.
Thanks..:)
We need to initiate the Solo object. After initiation, we will uses solo to get those.
For Single web element :
Solo object have a function named solo.getWebElement(), where we use two parameter to get element. First parameter is for element finder(By object) and 2nd one is the index(nth found), So
-The function returns a web element
-We need to specify By object( the object finder)
-We need to specify index. (Zero based integer index and in here 0 means found 1)
-To select a web element by its class name(Actually it is the type name defines what type of web element that is, like button, text box etc)
solo.getWebElement(By.className("Textbox"),0);
-To select a web element by its css selector
solo.getWebElement(By.cssSelector("CSSAsString"),0);
-To select a web element by its ID
solo.getWebElement(By.id("idAsString"), 0);
-To select a web element by its Name
solo.getWebElement(By.name("NameAsString"), 0);
-To select a web element by itsTag Name
solo.getWebElement(By.tagName("tagNameAsString"), 0);
-To select a web element by its text content
solo.getWebElement(By.textContent("contentAsString"), 0);
-To select a web element by its Xpath
solo.getWebElement(By.xpath("xpathAsString"), 0);
For Multiple web element :
There are two function,
1. solo.getCurrentWebElements(By.[--by xpath or above items--])
This is just multiple version of previous single web element finding
2. solo.getCurrentWebElements();
For both cases they provide an array list of WebElements displayed in the active WebView.
Thanks..:)