Jump to content

Recommended Posts

Posted

Greetings, all. At my wit's end trying to read element properties derived from css using IE.au3.

The information here seems not to work for me, sadly. Anyway, my test case should be the best explanation.

 

#include <IE.au3>

Local $window_width = 640
Local $window_height = 480

$oIE = _IECreate()

Local $sHTML = ""
$sHTML &= "<HTML>" & @CR
$sHTML &= "<TITLE>UNIQUE IDENTIFIER FOR WINDOW CLOSE</TITLE>" & @CR
$sHTML &= "<HEAD>" & @CR
$sHTML &= '<STYLE>.image_div {background-image: url("http://i.imgur.com/T8A46Yb.png"); width: 256px; height: 256px;}</STYLE>' & @CR
$sHTML &= "</HEAD>" & @CR
$sHTML &= '<body><table><tbody><tr><td id="my_div" class="image_div"></td></tr></tbody></table></body></html>'



_IEDocWriteHTML($oIE, $sHTML)
_IEAction($oIE, "refresh")

Local $my_div = _IEGetObjById($oIE, "my_div")


;I'm trying to examine the DOM and SOMEHOW get the "http://i.imgur.com/T8A46Yb.png" address

;these seem to return empty strings
ConsoleWrite(@CRLF & '$my_div.getAttribute("style") - ' & $my_div.getAttribute("style"))
ConsoleWrite(@CRLF & '$my_div.getAttribute("background-image") - ' & $my_div.getAttribute("background-image"))
ConsoleWrite(@CRLF & '$my_div.getAttribute("cssText") - ' & $my_div.getAttribute("cssText"))


;these return zero
ConsoleWrite(@CRLF & '$my_div.style.csstext - ' & $my_div.style.csstext)
ConsoleWrite(@CRLF & '$my_div.style.cssText - ' & $my_div.style.cssText)
ConsoleWrite(@CRLF & '$my_div.style.CSSText - ' & $my_div.style.CSSText)



ConsoleWrite(@CRLF)

sleep(5000)

WinClose("UNIQUE IDENTIFIER FOR WINDOW CLOSE")

Basically I'm trying to get the src of a background image set through css. Any help would be much appreciated.

Thank you for your time.

Posted (edited)

I'm not sure what exactly you need but try to read this:

There is a function to grab CSS styles and save them to HTML file.


EDIT

:welcome: to the forum.

 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

I found that since I posted, and I'm making some progress with it, but it'd be really nice if I could get the property from the element without parsing the entire stylesheet, which is what I'm currently working on.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...