简体   繁体   中英

Cucumber Java. I’m having issues trying to build a boolean method

Cucumber Java. I'm having issues trying to build a boolean method that would do a assert where I want to validate: when I filter 50, the results would show 50. I'm trying to compare class="ng-scope active" selector with probably say linktext: 50

assert getElementTextBy(By.xpath("//li[@class='ng-scope active']")).equals(By.xpath("//a[@class='ng-binding'][contains(text(),'50')]"));

Any ideas how I can get the right form?

enter image description here

You compare text with WebElement.

Add get text for the second part also.

assert getElementTextBy(By.xpath("//li[@class='ng-scope active']")).equals(getElementTextBy(By.xpath("//a[@class='ng-binding'][contains(text(),'50')]")));

If your input is 50 and you expect 50, you could only check that getElementTextBy(secondeElement).equals("50") , look for improvements.

Does not make much sense to say equal to a getText of an element that you identify based on the condition that has text 50.

filter by 50 => check there is a filter for 50, where 50 is the input from your test, so there is a known value.

If you need to check 2 elements then i would do 2 asserts and for each element i would check the text

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM