RobotFramework Python Get Text from inside a javascript function

Get Text in Selenium/SeleniumLibrary returns the visible text in a tag – e.g. what the browser renders in the viewport. Naturally, anything that is in a <script> is not that – it’s code that will be executed (regardless what it’ll do – put some text out there or not, it is code).

You can still get the tag’s content though – every DOM element has an attribute innerHTML, that is its raw content (before rendering and so on). So try this:

${response}    Get Element Attribute   css=body script:nth-child(9)    innerHTML

This will of course return you everything (because the response is the raw content) – "Metro.toast.create(", etc – so you’ll have to manipulate the output a bit, to get just the method’s argument.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top