first of all forgive my ignorance, I’ve only been working with automation a few days and I’m a total noob. I probably have the wording wrong too.
I’m trying to get the value of a hidden span element.
I first use “waitForElementPresent” so I know it’s there.
then I use:
String tag = selenium.getText (‘css=span.eg’)
but all I get is "null’ instead of the text inside.
If I simply put
click selenium.click (‘css=span.eg’), it works just fine. The link works just fine
One thing that maybe the problem is that on some pages there are several instances of this “span”. Could that be the problem?
Thanks and sorry for this
.getText() (note there’s nothing inside the brackets) should get the innerHTML property, but if your element doesn’t have any innerHTML, but instead has text written (e.g. it is an input element),
.getAttribute('value') should get you what you need.
Anyway, this is just some guesswork, if I didn’t hit anything, follow the advice given here:
I’ve had so many chances to link to this topic that you’d almost think the majority of Katalon users work in QA or something…
From the behavior you describe I suspect that the span actually doesn’t contain any text. Can you provide a screenshot of the HTML page ? You can obtain it by right click on the span -> Inspect.
Thanks for your suggestios.
I got it using
String tag = WebUI.getAttribute(findTestObject(‘Untitled test case/span.eg’), ‘innerText’) and in the object repsitory I used “css selector” only.
The same also worked with Selenium:
WebElement element= driver.findElement(By.cssSelector()) ;