0

I am automating a web application based on PEGA for my organization using Selenium. A PEGA application has lots of iframes.

My problem is: I have a table on Page A displaying some search results. If I select any one of the rows, then click Submit button, next page is loaded. Page B (next page) contains a dropdown which I have to validate that it contains the exact same values which I selected from the table on Page A.

All my other automation scenarios work perfectly fine by switching into frames and then into default content. But, this scenario does not allow me to pass onto the search result on Page A (using ArrayList) to Page B (containing another ArrayList). I have to compare these two Arraylists, the only issue is the passing/accessing of data across frames.

1 Answers1

0

Assuming you are using the Selenium Java Client we can take help of the Java Collection to compare 2 ArrayList. Here is a sample prototype for your reference:

//Switch to the first frame
driver.switchTo().frame("firstFrame"); 
//Collect the WebElements, retrive the text and save in a List
List<WebElement> team_member = driver.findElements(By.xpath("xpathA"));
List<String> mem_name_list = new ArrayList<String>();
for (WebElement member:team_member)
{
    String memeber_name = member.getAttribute("innerHTML");
    mem_name_list.add(memeber_name);
}
//Switch back to Top Window
driver.switchTo().defaultContent();
//Switch to the second frame
driver.switchTo().frame("secondFrame");
//Collect the WebElements, retrive the text and save in a List
List<WebElement> team_member_images = driver.findElements(By.xpath("//main[@id='content']//div[@class='team-members']/div[@class='team-member']/div[@class='team-member-portrait']/img"));
List<String> mem_image_list = new ArrayList<String>();
for (WebElement image_link:team_member_images)
{
    String memebr_image = image_link.getAttribute("src");
    mem_image_list.add(memebr_image);
}
//Switch back to Top Window
driver.switchTo().defaultContent();
//Assert the two List<String> in a loop
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Ok, my implementation is very similar to yours, the only major difference is that when I have to verify the values in dropdown on Page B, I was not adding the dropdown values in a new arraylist [using list.add(value)], instead I was trying to assign the values of ArrayList created for Page A to a new empty ArrayList created for Page B. I will try adding the dropdown values [using list.add(value)] on Page B as well, and then compare the two Arraylists.The issue I am encountering is of null value while assigning ArrayList A to ArrayList B, I would try something similar to yours and update you. – niraj panchal Oct 25 '17 at 14:51
  • 1
    I have been able to make my test script working based on part of your logic and part of my own logic. Thanks. – niraj panchal Oct 26 '17 at 11:56