CS agents will respond to tickets via forum instead of private helpdesk to support other users with similar issues.

How get diffrent text from the same object?

Hi there,
maybe anyone know how get text from this few fields?

They have the same xpath, title etc.;/

Comments

  • edited October 10

    Hi there,

    you can try while-loop to get all those attributes. (path may be simplified! Provide full path to a variable)

    int i = 1
    String path = ".//li[" + i + "]/div/span"
    List results = new Arraylist()
    TestObject to = new TestObject().addProperty("xpath", ConditionType.EQUALS, path)
    
    while (WebUI.verifyElementPresent(to, 1, FailureHandling.OPTIONAL)) {
        results.add(WebUI.getAttribute(to, "text"))
        i++
        path = ".//li[" + i + "]/div/span"
        to = new TestObject().addProperty("xpath", ConditionType.EQUALS, path)
    }
    
  • I can get all this text when I use getText for general div. But later I would like to compare Strings and all text at once will never be equal :(

  • Not sure what you wanna compare. A content of "text" attribute with what?

  • In the application I have products which I add to the cart. After this I go to the summary of purchases and i would like check the items I add are in the cart.

Sign In or Register to comment.