A quick tip, FYI - use three back ticks (```) before and after any html or code so to doesn’t get messed up.
What is the result of your code?:
does it error on the Get Text step?
what was the error?
does it get to the Log step?
what does it log?
I would start by checking the html if there is more than one element that matches you css selector (especially ones that are in div’s that are disabled or hidden)
The fact you got a blank indicates that there is more than one element that matched that css selector and the first one it matched is not the one you want.
Go back to the html of the page and see if you can find them all and try and work out a css selector that will uniquely find the span you want
It may be as simple as .case-id .case_title or span.case_title, but it might also be more involved than that.
If you still can’t figure it out you could try adding something like this before the Get Text line:
# this should show you if you get more than one
${webelements}= Get WebElements css=.case_title
Log ${webelements}
# this will give you more info on what you selected
${webelement}= Get WebElement css=.case_title
Log ${webelement}
Log ${webelement.get_attribute('innerHTML')}
Log ${webelement.get_attribute('outerHTML')}
That should help you identify if in fact you are selecting the wrong case_title element
You could try to use the id, if it is static for the run of the testcase
So
${number} get text id=201905…
and if it works then maybe making another CSS/xpath selector
${number} get text css=[class=“case_title”]
${number} get text css=span[data-template]
${number] get text //span[@class=“case_title”]
Unfortunately the number is not a static value. This is number is always new generated in case of creating new cases with our tool. So I have to save this number to proceed further in our process. There are one workaround which I can use but I would like to avoid this, however, because I might then select the wrong case
This looks to me like it might be the value is empty when the page is loaded from the server and gets filled in by some client side java script, in that case you might need to wait for the java script to finish first.
See if you can use one of the Wait Until * keywords (maybe on another element?) to determine that it’s finished
You may also need to try using Execute Javascript to check document.readyState returns “complete”
Failing all that as a last resort use a simple loop like this:
${element}= Get Text css=.case_title
WHILE len(${element}) < 1
Sleep 0.1
${element}= Get Text css=.case_title
END
Set Global Variable ${element}
Log ${element}
Be warned that could leave you in an endless loop so you may need to put a counter with a break point in that loop. Those Wait Until keywords already have the endless loop protections in them, so they should be your first resort.
Thank you for these tips. I was able to solve my problem thanks to the Java Script info. I simply waited until the script was finished or I simply put the query at the end. Thanks again