Jump to content

Help finding text in Chrome


Recommended Posts

I hope I have this posted in the proper forum, if not, please advise.

I am a first time user of AutoIT and I am trying to develop a script to find text in a Chrome web page. The page is an Amazon page which had some analytics run on it, and for lack of a better term re-displayed with the analytics overlaid on the original page. If I highlight the text I am looking for and inspect the element in Chrome it yields something like this:

<div id="id_Im_looking_for" style="">Text I highlighted.</div>

Using $sText = _ChromeObjGetValueByName("id_Im_looking_for") or $sText = _ChromeObjGetValueById("id_Im_looking_for") always return $sText with a null value.

If I use the code below to highlight what I am looking for and do a PixelSearch the PixelSearch returns a result of 0 or an error. I have tried this with and without passing the WinHandle and my highlight color is magenta (0xFF00FF):

func _FoundText()
  Local $mResult = 1
  Local $hWnd = WinGetHandle("Amazon.com")
  Local $coord = PixelSearch(0, 0, @DesktopWidth, @DesktopHeight, 0xFF00FF, 0, 1, $hWnd)
  If @error Then
    $mResult = 0
  EndIf
  Return $mResult
 EndFunc

_send("^f")
sleep(500)
send("Text I highlighted.")
sleep(500)
send("{ESC}")
Sleep(500)
$strExists = _FoundText()

 

If I execute the script below, $sTitle returns the title of my Chrome window, but @error returns a 2 well before the 10 minute timeout.

Local $sTitle = WinGetTitle("[ACTIVE]")
_ChromeDocWaitForExistenceByTitle($sTitle, 10)
MsgBox($MB_SYSTEMMODAL, "WaitForExist", @error, 10)

I suspect I either have a configuration problem or problem with my install. I am using the  --force-renderer-accessibility switch to start Chrome and all the Global Accessibility check boxes under Accessibility internals are checked, Internal Show internal accessibility tree instead of native is not checked.

Link to comment
Share on other sites

AutoBert, thanks for the response. I started looking at that thread from the end backwards and I'm going to see if the WebDriver UDF produces better results for grabbing the title and waiting for the page to load.

In the meantime, I found that if I use send to issue a ctrl-c and clipget, I can get the text found with the ctrl-f into a variable, then search for what I am looking for in that variable. However, what I really need is the text at the end of the found line which is variable. I tried using send("(SHIFTDOWN)(RIGHT)(SHIFTUP)") and send("(SHIFTDOWN)(END)(SHIFTUP)"), but it will not select anymore of the line. The Shift-end is what I would really like to work. Any suggestions?

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...