Hi my code works My goal is to loop through each element in the table and and click the element so i can go to the next page basically I want to do this
1 click element form drop down 2 //code some stuff 3 Go back 4 click next element from drop down 5 code some stuff and etc
My code:
List<WebElement> CCTable = driver.findElements(By.id("companyIdBarCompListGrid_rows_scrollpane")); for ( WebElement client: CCTable) { System.out.println("\n"+client.getText().substring(0, 20)+"\n"); client.click(); Thread.sleep(10000); }
My problem is that its finding and printing out the text in my **console in eclipse ** but it is not clicking on the link or each link.
I am trying to follow the suggestions here https://sqa.stackexchange.com/questions/12790/how-to-iterate-over-a-collection-of-items-in-selenium-webdriver but no success any help would be appreciated.
If I am doing something wrong please help me. Any help would be appreciated
PP_OBJ_CycleData.CCdropdown(driver).click();
List<WebElement> CCTable = driver.findElements(By.cssSelector("div#companyIdBarCompListGrid_rows_scrollpane table tbody tr[id*=companyIdBarCompListGrid_] td span div a")); // inner 4 loop for ( WebElement ccode: CCTable) { System.out.println("\n"+ccode.getText().substring(0, 20)+"\n"); System.out.println("Number of links: " + CCTable.size()); Thread.sleep(3000); ccode.click(); Thread.sleep(5000); driver.findElement(By.xpath("//*[@id='companyIDBarContentPane']//span")); }// End Inner 4 loop PP_OBJ_CycleData.ReturnToSupport(driver);
Also this is in eclipse console:
Seems that the get text is not getting the other company code name. and it not looping through again after it clicks the first name and i click i get org.openqa.selenium.StaleElementReferenceException: stale element reference: element is not attached to the page document.