Could anybody tell me what is the xpath for the tick mark that i have highlighted in the screenshot
Because your element has ID so you don’t have to use xpath. Use the below -
driver.findElement(By.id("rel_agenda_completion"));
this didn’t work, since there are two elements with same name
xpath = (//*[@resource-id='org.wadhwanifoundation.learnwise.android:id/rel_agenda_completion'])[0]
with id driver.findElements(By.id("org.wadhwanifoundation.learnwise.android:id/rel_agenda_completion"))[0];
Store the elements in List when there are elements with same locator strategy and then iterate through each element and check for criteria. Because, in your case its just 2 elements so you can select element using index
List elementList = DRIVER.findElements(By.id(“rel_agenda_completion”));
elementList.get(0).click();
public void ClickOnAssignmentButton() throws InterruptedException{
System.out.println(eachAssignmentSegment.size());
int SizeOFSegments=eachAssignmentSegment.size();
for(int i=0; i<=SizeOFSegments; i++)
{
if(AssignIcon.get(0).isDisplayed())
{
AssignIcon.get(0).click();
Thread.sleep(2000);
}
else
{
CommonUtils CommonObj=new CommonUtils(driver);
CommonObj.swipingVertical("Bottom2Top");
}
}
}
this is the code
24
FAILED: verifyAssignment
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:635)
List<WebElement> elementList = DRIVER.findElements(By.id("rel_agenda_completion"));
Due to formatting was removed in above solution.
I tried this it is not working
It says FAILED: verifyAssignment, but the code you have posted is for class ClickOnAssignmentButton. When you check size for elementList what does it return?
If this is useful…
Create your own xpath - http://www.software-testing-tutorials-automation.com/2015/10/ui-automator-viewer-get-android-app.html
Hello,
In this case you can make the xpath with classname and resource-id .
i.e ("//classname[@id=‘resource-id’]");
could you please elobarate?
sure…
Dynamic xpath for checkbox is as follow:
findElement.By.xpath(//android.widget.RelativeLayout[@resource-id=‘rel-agenda_completion’]);
use the above xpath and perform click action on it …and please let me know if you face any error of it!!!
it worked that …I was thinking that id will not be having list…Now I come to know that id also has list
public void ClickOnAssignmentButton() throws InterruptedException{
while(true) {
if(tickmark.size() > 0) {
tickmark.get(0).click();
break;
}
CommonUtils CommonObj=new CommonUtils(driver);
CommonObj.swipingVertical("Bottom2Top");
Thread.sleep(2000);
}