Highlighted
Contributor.
Contributor.
894 views

relative XPATH of a node in LeanFT Java

I am trying a POC on  "advantageonlineshopping" site. And I am trying to Identify price of a product from a page.

I tried two scenaros and one is not working

At the first, I am trying to get all the Items that are listed in an array of type WebElement

WebElement[] imgsCnt=null;
WebElement ItemsWindow=browser.describe(WebElement.class,new Builder().className("cell categoryRight").build());
ItemsWindow.highlight();
imgsCnt=ItemsWindow.findChildren(WebElement.class,new Builder().className("ng-scope").build());

from the array imgsCnt object (imgsCnt has all the listed elements) , trying to identify "productPrice ng-binding" and it's getting the respective price of a product as expected

Scenario 1: [WORKING]

WebElement[] children = everyImg.findChildren(WebElement.class,new Builder().className("productPrice ng-binding").build());

Scenario 2: [NOT WORKING]

for(WebElement everyImg : imgsCnt){
WebElement[] childrenxpath = everyImg.findChildren(WebElement.class,new Builder().xpath("//P[1]/A[1]").build()); //
}

In scenario 2 tyring to identify using xpath as above. But it's returning around 10 child obejcts in array.

Page URL : http://www.advantageonlineshopping.com:8080/#/category/5

 

 

0 Likes
0 Replies
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.