Jump to content

chrome page text content acquisition


meety
 Share

Recommended Posts

@meety
If you want to retrieve something that is inside the page (a text from a DOM element), then you can use IE UDF;
if that's not the case, then, as stated above, you need to be more explicit and provide a working sample :)

Edited by FrancescoDiMuro

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

3 hours ago, meety said:

Did I make it clear?

Very clear.  With Chrome you cannot use _IE* functions.  You need to use WebDriver as you were already told.  We will not spoon-feed you with the code.  You will need to go thru Wiki to learn how to install WebDriver, then go thru all examples (and other materials) to understand how it is working.  After creating your script, if you still have problem, please come here with your code, and we will gladly help you out.

Edited by Nine
Link to comment
Share on other sites

12 hours ago, Nine said:

Very clear.  With Chrome you cannot use _IE* functions.  You need to use WebDriver as you were already told.  We will not spoon-feed you with the code.  You will need to go thru Wiki to learn how to install WebDriver, then go thru all examples (and other materials) to understand how it is working.  After creating your script, if you still have problem, please come here with your code, and we will gladly help you out.

Can you give an example, such as using with wingettext to fetch the text content on the page?thank you!

Link to comment
Share on other sites

After downloading all the required documents listed in my first link above, install them in one folder. Then you should study _wd_demo.au3 and wiki page to understand how it works. For getting the text of a web page, you can try this:
 

#include "wd_core.au3"

Local $sDesiredCapabilities, $sSession
$_WD_DEBUG = $_WD_Debug_Info
$_WD_ERROR_MSGBOX = False
SetupChrome()
If Not ProcessExists("chromedriver.exe") Then
    _WD_Startup()
EndIf
If @error <> $_WD_ERROR_Success Then
    Exit
EndIf

$sSession = _WD_CreateSession($sDesiredCapabilities)
If @error <> $_WD_ERROR_Success Then
    Exit
EndIf

_WD_Navigate($sSession,  "https://google.com")
$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "/html/body")
$sText = _WD_ElementAction($sSession, $sElement, "text")

MsgBox(0, '', $sText)

Func SetupChrome()
    _WD_Option('Driver', 'chromedriver.exe')
    _WD_Option('Port', 9515)
    _WD_Option('DriverParams', '--verbose --log-path="' & @ScriptDir & '\chrome.log"')

    $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "excludeSwitches": [ "enable-automation"], "useAutomationExtension": false }}}}'
EndFunc

 

Link to comment
Share on other sites

53 minutes ago, CYCho said:

After downloading all the required documents listed in my first link above, install them in one folder. Then you should study _wd_demo.au3 and wiki page to understand how it works. For getting the text of a web page, you can try this:
 

#include "wd_core.au3"

Local $sDesiredCapabilities, $sSession
$_WD_DEBUG = $_WD_Debug_Info
$_WD_ERROR_MSGBOX = False
SetupChrome()
If Not ProcessExists("chromedriver.exe") Then
    _WD_Startup()
EndIf
If @error <> $_WD_ERROR_Success Then
    Exit
EndIf

$sSession = _WD_CreateSession($sDesiredCapabilities)
If @error <> $_WD_ERROR_Success Then
    Exit
EndIf

_WD_Navigate($sSession,  "https://google.com")
$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "/html/body")
$sText = _WD_ElementAction($sSession, $sElement, "text")

MsgBox(0, '', $sText)

Func SetupChrome()
    _WD_Option('Driver', 'chromedriver.exe')
    _WD_Option('Port', 9515)
    _WD_Option('DriverParams', '--verbose --log-path="' & @ScriptDir & '\chrome.log"')

    $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "excludeSwitches": [ "enable-automation"], "useAutomationExtension": false }}}}'
EndFunc

 

Thank you for your answer. My requirement is to monitor whether an open page changes. So I thought of using wingstext to fetch the content of the page regularly to determine whether the page has changed

Link to comment
Share on other sites

Hello!

I have a requirement to open www.google.com with chrome and keep it open, and then periodically check the text on the page to determine whether the page has changed. Can this autoit be realized?

Edited by meety
Link to comment
Share on other sites

10 hours ago, meety said:

I have a requirement to open www.google.com with chrome and keep it open, and then periodically check the text on the page to determine whether the page has changed.

Why do you think the content of a Google search result would dynamically change without any user intervention?

Edited by TheXman
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

×
×
  • Create New...