Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dom() returns empty string - that is within a frame, see this easier example #520

Closed
Kellesc opened this issue Feb 13, 2024 · 2 comments
Closed
Labels

Comments

@Kellesc
Copy link

Kellesc commented Feb 13, 2024

Hi,

Once more thank you for your great job!

I am trying to use dom() function to get the style of an element.

For instance from this page (https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_document_getelementbyid1)

I tried:
r.dom('return document.getElementById("demo").style')
r.dom('return document.querySelector("demo").style')
and other options , I always get '' as output. Adding r.echo I just get True.

I have seen examples from
#49
#295
and others; whatever I try returns an empty string.

What am I missing?
Thanks

@kensoh
Copy link
Member

kensoh commented Aug 8, 2024

Hi @Kellesc sorry for late reply I just got to work on the GitHub issues!

This is because on that webpage there are various frames. The dom() is assessing the primary parent frame.

To do what you want you can use the @ attribute in XPath to read the style value - see example below

>>> r.url("https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_document_getelementbyid1")
True
>>> r.frame('iframeResult')
True
>>> r.read('//*[@id="demo"]/@style')
'color: red;'

@kensoh
Copy link
Member

kensoh commented Aug 8, 2024

(closing issue for now)

@kensoh kensoh added the query label Aug 8, 2024
@kensoh kensoh changed the title dom() returns empty string dom() returns empty string - that is within a frame, see this easier example Aug 8, 2024
@kensoh kensoh closed this as completed Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants