I want to verify if the text contained inside this paragraph is correct but I cannot get the text and make it into object. I used Verify Element Text but so far, I was just able to use it in the text inside the <strong> <strong> tag. I want to check the other text inside the <p> </p> too but can’t do so because there is a <strong> </strong> tag and a <br> inside. Here’s a snippet of what I was referring to.
I used chroPath to capture the element and make it into object. I stored the captured xpath into a label_companyPolicy_1 object. After doing so, I used the Get Text keyword but in the Script View, I stored the value of the Get Text into a variable name called companyPolicy in order for me to use this variable in the actualObject Field. However, after doing the steps above, still I wasn’t able to verify if the text inside the paragraph is equivalent to my expectedObject.
Sorry, I can’t figure out what’s going wrong there. I don’t use Test Objects - they make this kind of thing unnecessarily complicated. Maybe someone else can help…
Oh. Okay. But you mentioned to use Get Text. Can I ask how would you do it on your end using the Get Text keyword? I guess we need to use Test Objects because that is going be the basis of what we are expecting? Correct me if I’m wrong.
Both getText and verifyElementText use element.getText(), so there should be no discrepancies.
@mark.jabay
Can you place getText from the element, print it out, and then use that text in verifyElementText to see if the result from getText is as expected and wether the result is usable in verifyElementText ? Something like this
String text = WebUI.getText(findTestObject('your Element'));
println text;
WebUI.verifyElementText(findTestObject('your element'), text);
As mentioned in the post above, there is a <br> after the words Work Week<br> A Work Week is composed of five (5) working days and two (2) Rest Days, except for Holidays.
Here’s the script:
String companyPolicy = WebUI.getText(findTestObject('View Shift/label_companyPolicy_1'), FailureHandling.STOP_ON_FAILURE)
System.out.println(companyPolicy)
WebUI.verifyElementText('View Shift/label_companyPolicy_1', 'Work Week A Work Week is composed of five (5) working days and two (2) Rest Days, except for Holidays.')
Okay, guys. thank you so much for the help. I was able to find a solution. I just used \n instead <br> and it worked so well. Again, thank you very much for the help.