Help to Solve the Problem | Selenium Forum
M
Posted on 26/10/2016
Hi Ashish,
I am stuck in one condition so please help me. This is inline project in my Org. In this i want to assign few material to an engineer.



List<WebElement> chckbox= driver.findElements(By.xpath("//input[@id='Checkbox']"));
System.out.println("Total Records are -- > " + chckbox.size());

int i=0;
while(i!=2){
WebElement checkBox = driver.findElement(By.xpath("//input[@id='Checkbox']"));
checkBox.click();
i++;
}


[b:235nfxx1]This code click only once. i am not able to create correct Xpath for second check box. so please help[/b:235nfxx1]

Please refer attached screen shot for better understand.

M
Replied on 26/10/2016

Please suggest.

List<WebElement> chckbox= driver.findElements(By.xpath("//input[@id='Checkbox']"));
System.out.println("Total Records are -- > " + chckbox.size());

int i=0;
while(i!=2){
WebElement checkBox = [b:36zil2pi]driver.findElement([b]By.xpath("//input[@id='Checkbox'][/b:36zil2pi]"))[/b]; ====> [b:36zil2pi]According to me xpath not correct[/b:36zil2pi].
checkBox.click();
i++;
}

[b:36zil2pi]====>> I debug it and observe that issue is in my xpath because in first iteration it check by first checkbox but when it goes to second
iteration it again click on the first check box so that first check box is unchecked. it does not click on second check box.[/b:36zil2pi]


M
Replied on 28/10/2016

?


M
Replied on 31/10/2016

No update from your side????


M
Replied on 01/11/2016

[quote="SamSelenium":t2vokc4q]No update from your side????[/quote:t2vokc4q]
we were on holidays past couple of days.

ids cannot be same of 2 elements tell the developer of the website that they have made a mistake. tell them to fix it.