Jump to content

Check the text changes in the Сhrome window.


Recommended Posts

6 hours ago, jdelaney said:

Do a 'Chrome' search on this site...specifically in the example scripts forum...plenty of UDFs devoted to just that.

Thanks for your reply. But I do not want to install an extension for Chrome. Are there any other options?

Link to post
Share on other sites

Use Internet Explorer.  Or, copy the whole page, and do a regexp to find your text change. 

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to post
Share on other sites
5 hours ago, zxc3 said:

Thanks for your reply. But I do not want to install an extension for Chrome. Are there any other options?

See FAQ 31, particularly IUIAutomation here

 

That is your recourse, or what @jdelaney said

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Link to post
Share on other sites

so you are telling me you have not even google searched it before asking? 

google this "copy source of webpage in autoit"

i just tested a solution and it read my source from chrome. check it, from an old post, this will retrieve just the text, not the source, which is what I THINK you want, I am probably wrong

ConsoleWrite(_INetGetText('https://www.autoitscript.com/forum/') & @LF)

Func _INetGetText($sURL)
    Local $bStr = InetRead($sURL, 19)
    If @error Then
        Return SetError(1, 0, 0)
    EndIf

    Local $oHTML = ObjCreate("HTMLFILE")
    If @error Then Return SetError(2, 0, 0)

    $oHTML.Open()
    $oHTML.Write(BinaryToString($bStr))

    ; $oHTML....

    Return SetError(0, 0, $oHTML.Body.InnerText)
EndFunc ;==>_INetGetText

running that on the forum page I get this output

--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
Jump to content 



 
Existing user? Sign In   
  
Sign In



 
 
  
Remember me Not recommended on shared computers 
  
Sign in anonymously 

Sign In 

Forgot your password? 
Or sign in with one of these services


Sign in with Facebook 
Sign in with Microsoft 
Sign Up 
All Content  
All Content 




Advanced Search 
 
Browse 
Forums 
Downloads 
Guides 
Calendar 
Forum Rules 
More 
Wiki 
AutoIt Resources 
Release 
Installer 
Help file 
Editor 
Beta 
Installer 
Help file 
Editor 
Git 
More 
More 
All Activity 
Home 

Forums
General 
Announcements and Site News 
AutoIt releases and site announcements.
310 
posts 
 
AutoIt v3.3.14.3 Released 
By Jon 
6 hours ago 
Chat 
General chat for Active Members. Not accessible to guests or search engines.
172,478 
posts 
 
By AZJIO 
1 hour ago 
Administration 
User Moderation 
364 
posts 
 
Nikolas92 
By Melba23 
November 26, 2017 
AutoIt v3 
AutoIt Help and Support 
AutoIt General Help and Support 
AutoIt GUI Help and Support 
AutoItX Help and Support 
Old AutoIt v2 Help and Support 
Help and support for AutoIt. 
881,739 
posts 
 
Check the text changes in … 
By Earthshine 
10 minutes ago 
AutoIt Technical Discussion 
AutoIt Projects and Collaboration 
Technical discussions, betas, editors, help file, add-on tools, etc.
34,436 
posts 
 
is the new version of auto… 
By Melba23 
5 hours ago 
AutoIt Example Scripts 
Share your cool AutoIt scripts, UDFs and applications with others. 
158,076 
posts 
 
LCD Countdown Timer 
By Gattaca 
1 hour ago 
Scripting and Development 
Developer General Discussion 
General development and scripting discussions. If it's super geeky and you don't know where to put it - it's probably here. 
3,066 
posts 
 
what is a GUI you think of… 
By rcmaehl 
18 hours ago 
Language Specific Discussion 
PowerShell 
C# / .NET 
C++ / C / Win32 
VBScript 
JavaScript 
SQL 
Misc 
Common IT Admin-related languages have their own forums. Feel free to post about any other language in the Misc forum.
2,538 
posts 
 
Coded UI projects rule 
By Earthshine 
Tuesday at 04:23 PM 
IT Administration 
Operating System Deployment 
Microsoft Deployment Toolkit 
System Center Configuration Manager 
OS deployment and related technologies.
93 
posts 
 
Windows Pocess Database 
By satanico64 
January 15 
Windows Client 
Windows client and related technologies (Windows 10, 8, 7, XP, VDI, App-V, etc).
548 
posts 
 
Is that a Browser or Serve… 
By JLogan3o13 
December 20, 2017 
Windows Server 
Windows Server and related technologies (AD, Group Policy, etc).
76 
posts 
 
connect to new wifi networ… 
By JLogan3o13 
January 18 
Office 
Microsoft Office and related technologies (Office ProPlus, 365, deployment, etc).
243 
posts 
 
How To Make More Money As … 
By JLogan3o13 
January 12 
Who's Online   56 Members, 4 Anonymous, 932 Guests (See full list) 
AdamUL 
BrewManNH 
water 
Earthshine 
zaraijamel 
Melba23 
argumentum 
abdulrahmanok 
KiloLima 
krista611 
c.haslam 
SchneiMi 
Jasp402 
monter 
jordanrenault 
Moonscarlet 
smartkey 
Zedna 
WB123 
maniootek 
KarlosTHG 
JuanFelipe 
ChrisL 
funkey 
jpm 
Jfish 
rcmaehl 
mohanad4egy 
Ganreizu 
Autom8 
Pretend2Script 
gonzo070777 
Gattaca 
kalucas 
Wolfteeth 
Danp2 
qwert 
xHappyEnding 
genius257 
Corleone221 
TheSlig 
000000000 
ViciousXUSMC 
BrunoJ 
youtuber 
zxc3 
cbs803 
milos83 
jchd 
Danyfirex 
Bert 
Juvigy 
NguyenLe 
weirddave 
MLPerez007 
ArC 
General Statistics
169,270
Total Topics 
1,287,880
Total Posts 
72,851
Total Members 
4,882
Most Online 
 
Newest Member
tonycnx
Joined 02/02/2018 12:33 PM 
 
Popular Now
 
7
Browse a Intenet Webpage in a hidden mode 
By jordanrenault
Started 7 hours ago 
Latest Topic Updates
 
6
Check the text changes in the Сhrome window. 
By zxc3
Started 23 hours ago 
 
14
_ArraySort lacks ability to compare case-sensitively 
By c.haslam
Started 20 hours ago 
 
7
Browse a Intenet Webpage in a hidden mode 
By jordanrenault
Started 7 hours ago 
 
4
GUICtrlCreateTabItem("") Not working? 
By rcmaehl
Started 19 hours ago 
 
5
LCD Countdown Timer 
By timmy2
Started October 29, 2013 
Latest Files Updates
 
AD - Active Directory UDF
By water






   6941   5 
 
cDebug.au3
By c.haslam






   52   0 
 
OutlookEX
By water






   3289   0 
 
Beats Player
By careca






   1588   0 
 
UninstallByShortcut
By careca






   22   0 
All Activity 
Home 
Theme 
AutoIt (Default) 
AutoIt (Round Avatars) 
AutoIt (Forced Desktop View) 
AutoIt (Dark) 
Privacy Policy 
Contact Us 
Community Software by Invision Power Services, Inc. 
× 
Existing user? Sign In 
Sign Up 
Browse
Back 
Browse 
Forums 
Downloads 
Guides 
Calendar 
Forum Rules 
Wiki 
AutoIt Resources
Back 
Release
Back 
Installer 
Help file 
Editor 
Beta
Back 
Installer 
Help file 
Editor 
Git 
+>10:52:05 AutoIt3.exe ended.rc:0
+>10:52:05 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 2.091

 

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Link to post
Share on other sites
On 02.02.2018 at 6:41 PM, Earthshine said:

so you are telling me you have not even google searched it before asking? 

google this "copy source of webpage in autoit"

i just tested a solution and it read my source from chrome. check it, from an old post, this will retrieve just the text, not the source, which is what I THINK you want, I am probably wrong

ConsoleWrite(_INetGetText('https://www.autoitscript.com/forum/') & @LF)

Func _INetGetText($sURL)
    Local $bStr = InetRead($sURL, 19)
    If @error Then
        Return SetError(1, 0, 0)
    EndIf

    Local $oHTML = ObjCreate("HTMLFILE")
    If @error Then Return SetError(2, 0, 0)

    $oHTML.Open()
    $oHTML.Write(BinaryToString($bStr))

    ; $oHTML....

    Return SetError(0, 0, $oHTML.Body.InnerText)
EndFunc ;==>_INetGetText

running that on the forum page I get this output

--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
Jump to content 



 
Existing user? Sign In   
  
Sign In



 
 
  
Remember me Not recommended on shared computers 
  
Sign in anonymously 

Sign In 

Forgot your password? 
Or sign in with one of these services


Sign in with Facebook 
Sign in with Microsoft 
Sign Up 
All Content  
All Content 




Advanced Search 
 
Browse 
Forums 
Downloads 
Guides 
Calendar 
Forum Rules 
More 
Wiki 
AutoIt Resources 
Release 
Installer 
Help file 
Editor 
Beta 
Installer 
Help file 
Editor 
Git 
More 
More 
All Activity 
Home 

Forums
General 
Announcements and Site News 
AutoIt releases and site announcements.
310 
posts 
 
AutoIt v3.3.14.3 Released 
By Jon 
6 hours ago 
Chat 
General chat for Active Members. Not accessible to guests or search engines.
172,478 
posts 
 
By AZJIO 
1 hour ago 
Administration 
User Moderation 
364 
posts 
 
Nikolas92 
By Melba23 
November 26, 2017 
AutoIt v3 
AutoIt Help and Support 
AutoIt General Help and Support 
AutoIt GUI Help and Support 
AutoItX Help and Support 
Old AutoIt v2 Help and Support 
Help and support for AutoIt. 
881,739 
posts 
 
Check the text changes in … 
By Earthshine 
10 minutes ago 
AutoIt Technical Discussion 
AutoIt Projects and Collaboration 
Technical discussions, betas, editors, help file, add-on tools, etc.
34,436 
posts 
 
is the new version of auto… 
By Melba23 
5 hours ago 
AutoIt Example Scripts 
Share your cool AutoIt scripts, UDFs and applications with others. 
158,076 
posts 
 
LCD Countdown Timer 
By Gattaca 
1 hour ago 
Scripting and Development 
Developer General Discussion 
General development and scripting discussions. If it's super geeky and you don't know where to put it - it's probably here. 
3,066 
posts 
 
what is a GUI you think of… 
By rcmaehl 
18 hours ago 
Language Specific Discussion 
PowerShell 
C# / .NET 
C++ / C / Win32 
VBScript 
JavaScript 
SQL 
Misc 
Common IT Admin-related languages have their own forums. Feel free to post about any other language in the Misc forum.
2,538 
posts 
 
Coded UI projects rule 
By Earthshine 
Tuesday at 04:23 PM 
IT Administration 
Operating System Deployment 
Microsoft Deployment Toolkit 
System Center Configuration Manager 
OS deployment and related technologies.
93 
posts 
 
Windows Pocess Database 
By satanico64 
January 15 
Windows Client 
Windows client and related technologies (Windows 10, 8, 7, XP, VDI, App-V, etc).
548 
posts 
 
Is that a Browser or Serve… 
By JLogan3o13 
December 20, 2017 
Windows Server 
Windows Server and related technologies (AD, Group Policy, etc).
76 
posts 
 
connect to new wifi networ… 
By JLogan3o13 
January 18 
Office 
Microsoft Office and related technologies (Office ProPlus, 365, deployment, etc).
243 
posts 
 
How To Make More Money As … 
By JLogan3o13 
January 12 
Who's Online   56 Members, 4 Anonymous, 932 Guests (See full list) 
AdamUL 
BrewManNH 
water 
Earthshine 
zaraijamel 
Melba23 
argumentum 
abdulrahmanok 
KiloLima 
krista611 
c.haslam 
SchneiMi 
Jasp402 
monter 
jordanrenault 
Moonscarlet 
smartkey 
Zedna 
WB123 
maniootek 
KarlosTHG 
JuanFelipe 
ChrisL 
funkey 
jpm 
Jfish 
rcmaehl 
mohanad4egy 
Ganreizu 
Autom8 
Pretend2Script 
gonzo070777 
Gattaca 
kalucas 
Wolfteeth 
Danp2 
qwert 
xHappyEnding 
genius257 
Corleone221 
TheSlig 
000000000 
ViciousXUSMC 
BrunoJ 
youtuber 
zxc3 
cbs803 
milos83 
jchd 
Danyfirex 
Bert 
Juvigy 
NguyenLe 
weirddave 
MLPerez007 
ArC 
General Statistics
169,270
Total Topics 
1,287,880
Total Posts 
72,851
Total Members 
4,882
Most Online 
 
Newest Member
tonycnx
Joined 02/02/2018 12:33 PM 
 
Popular Now
 
7
Browse a Intenet Webpage in a hidden mode 
By jordanrenault
Started 7 hours ago 
Latest Topic Updates
 
6
Check the text changes in the Сhrome window. 
By zxc3
Started 23 hours ago 
 
14
_ArraySort lacks ability to compare case-sensitively 
By c.haslam
Started 20 hours ago 
 
7
Browse a Intenet Webpage in a hidden mode 
By jordanrenault
Started 7 hours ago 
 
4
GUICtrlCreateTabItem("") Not working? 
By rcmaehl
Started 19 hours ago 
 
5
LCD Countdown Timer 
By timmy2
Started October 29, 2013 
Latest Files Updates
 
AD - Active Directory UDF
By water






   6941   5 
 
cDebug.au3
By c.haslam






   52   0 
 
OutlookEX
By water






   3289   0 
 
Beats Player
By careca






   1588   0 
 
UninstallByShortcut
By careca






   22   0 
All Activity 
Home 
Theme 
AutoIt (Default) 
AutoIt (Round Avatars) 
AutoIt (Forced Desktop View) 
AutoIt (Dark) 
Privacy Policy 
Contact Us 
Community Software by Invision Power Services, Inc. 
× 
Existing user? Sign In 
Sign Up 
Browse
Back 
Browse 
Forums 
Downloads 
Guides 
Calendar 
Forum Rules 
Wiki 
AutoIt Resources
Back 
Release
Back 
Installer 
Help file 
Editor 
Beta
Back 
Installer 
Help file 
Editor 
Git 
+>10:52:05 AutoIt3.exe ended.rc:0
+>10:52:05 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 2.091

 

Thanks, but it does not work for me. What does it take to make it work?

Link to post
Share on other sites
  • 1 month later...

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By mLipok
      Recently I start wd_capabilities.au3 project on my side.
      I think this is time to share to AutoIt community.
      Check attached UDF: wd_capabilities.au3

      Here is a scratch example showing how to use them:
      #include "wd_helper.au3" #include "wd_capabilities.au3" _Example() Func _Example() ........ ........ ........ _WD_Capabilities_Build_Arguments(Null) ; CLEANUP ARGS _WD_Capabilities_Build_Arguments('--headless') _WD_Capabilities_Build_Arguments('start-maximized') _WD_Capabilities_Build_Arguments('disable-infobars') _WD_Capabilities_Build_Arguments('user-data-dir', 'C:\Users\' & @UserName & '\AppData\Local\Google\Chrome\User Data\Default') Local $s_WD_Capabilities_Arguments = _WD_Capabilities_Build_Arguments(Default) ; GET ARGS _WD_Capabilities_Build_Preferences(Null) ; CLEANUP PREFS If $s_Download_dir Then _WD_Capabilities_Build_Preferences('download.default_directory', $s_Download_dir) Local $s_WD_Capabilities_Preferences = _WD_Capabilities_Build_Preferences(Default) ; GET PREFS Local $s_Desired_Capabilities = _WD_Capabilities_Build_JSON('chrome', $s_WD_Capabilities_Arguments, $s_WD_Capabilities_Preferences) Local $WD_SESSION = _WD_CreateSession($s_Desired_Capabilities) ........ ........ ........ EndFunc  
      I plan to publish the code on GitHub.
      In the indefinite future, when the project becomes more functional, if @Danp2 accepts it, I hope it may be included in the main WebDriver UDF.

      I am waiting for yours feedback and help in the further development of this project.

      REMARK 1:
      As so far this UDF only supports GoogleChrome.
      Adding support for other browsers shouldn't be difficult, I just didn't need to.

      REMARK 2:
      For now, this project is working but still as a early BETA, so please do not discuss, ask questions, or post examples or snippets of code that pertain to any function of this UDF in other part of this forum, until it is found acceptable. Simply: discusion and tests only here in this topic.


      Regards,
      @mLipok
       
    • By Hermes
      I have Index.html where it contains a frame with a source "frame1.html". I can select/highlight elements in index.html but unable to select/highlight elements inside the frame with the src "frame1.html", the autoit output is throwing error:
      __WD_Post: URL=HTTP://127.0.0.1:9515/session/2143396006437be4005db3b84acc1496/element/8be1c3c4-5bb1-42b1-8cde-7954765cbc61/element; $sData={"using":"css selector","value":"frameset:nth-of-type(1)"} __WD_Post: StatusCode=404; ResponseText={"value":{"error":"no such element","message":"no such element: Unable to locate element: {\"method\... __WD_Post ==> No match: {"value":{"error":"no such element","message":"no such element: Unable to locate element: {\"method\":\"css selector\",\"selector\":\"frameset:nth-of-type(1)\"}\n (Session info: chrome=90.0.4430.212)","stacktrace":"Backtrace:\n\tOrdinal0 [0x00FCE7D3+124883]\n\tOrdinal0 [0x00FCE7B1+124849]\n\tGetHandleVerifier [0x01218688+193832]\n\tGetHandleVerifier [0x0123C478+340760]\n\tGetHandleVerifier [0x012361F1+315537]\n\tGetHandleVerifier [0x012516BA+427354]\n\tGetHandleVerifier [0x01236176+315414]\n\tGetHandleVerifier [0x0125174A+427498]\n\tGetHandleVerifier [0x0125D6EB+476555]\n\tGetHandleVerifier [0x0125154B+426987]\n\tGetHandleVerifier [0x01234FFD+310941]\n\tGetHandleVerifier [0x01235D8E+314414]\n\tGetHandleVerifier [0x01235D19+314297]\n\tGetHandleVerifier [0x012F31EC+1089676]\n\tGetHandleVerifier [0x012F17C9+1082985]\n\tGetHandleVerifier [0x012F13A3+1081923]\n\tGetHandleVerifier [0x013ED9FD+2115741]\n\tOrdinal0 [0x0111B82E+1488942]\n\tOrdinal0 [0x010B5A7D+1071741]\n\tOrdinal0 [0x010B559B+1070491]\n\tOrdinal0 [0x010B54B1+1070257]\n\tOrdinal0 [0x010EFF53+1310547]\n\tBaseThreadInitThunk [0x770662C4+36]\n\tRtlSubscribeWnfStateChangeNotification [0x776B1B69+1081]\n\tRtlSubscribeWnfStateChangeNotification [0x776B1B34+1028]\n"}} Auto IT Script:
      #Include "wd_core.au3" #Include "wd_helper.au3" Local $sDesiredCapabilities, $sSession SetupChrome() _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, 'index.html') _WD_LoadWait($sSession) Local $index = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "frameset:nth-of-type(1)") Local $index1 = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "frameset:nth-of-type(1)", $index) Local $index2 = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "frame:nth-of-type(1)", $index1) Local $index3 = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "frameset:nth-of-type(1)", $index2) _WD_HighlightElement($sSession, $index2, 1) _WD_HighlightElement($sSession, $index3, 1) _WD_Shutdown() Func SetupChrome() _WD_Option('Driver', 'chromedriver.exe') _WD_Option('Port', 9515) _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["start-maximized","disable-infobars"]}}}}' EndFunc ;==>SetupChrome  

      frame1.html index.html
    • By SkysLastChance
      I am using web driver and xpaths to automate chrome. 
      I am able to edit everything I need to until I get these pop ups. Then when I try to find the xpath it act like it does not exist. 
      This code below is working to find input fields on the main page of the site. But, if I try the same thing for ones in the popover it will not find it. 😕
      $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//*[substring(@id, string-length(@id) - string-length('_3') + 1 ) = '_3']") _WD_ElementAction($sSession, $sElement, 'value', "TEST") Here is the html

      Any idea why it is not finding the element inside these pop overs?
       
       
      HTML:
       
    • By Hermes
      Hello, the script below will read column A from an excel file - and if a value matches in the browser, it will click the corresponding link and click on a specific button to paste the data, then writes "Completed" in Column B. It will continue to read from the excel file and do the same thing for all the remaining rows.
      #Include "Chrome.au3" #Include "wd_core.au3" #Include "wd_helper.au3" #Include "WinHttp.au3" #include <MsgBoxConstants.au3> #include <File.au3> #include <IE.au3> #include <Array.au3> #include <INet.au3> #include <AutoItConstants.au3> #include <WinAPIFiles.au3> #include <GDIPlus.au3> #include <Excel.au3> #Include "WinHttp.au3" #Include "_HtmlTable2Array.au3" Local $sDesiredCapabilities, $sSession SetupChrome() _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_LoadWait($sSession) _WD_Navigate($sSession, "table1.html") _WD_LoadWait($sSession) _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//table[@class='main']") Local $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//table[@class='main']") ;ConsoleWrite ("mat-table " & $sElement & @CRLF) Local $aArray1 = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, ".//td[contains(@class,'data')]", $sElement, True) sleep(1000) For $i = 0 to UBound($aArray1) - 1 $aArray1[$i] = _WD_ElementAction($sSession, $aArray1[$i], 'text') Next ;_ArrayDisplay($aArray1) ;Email variables $SmtpServer = "" ; address for the smtp-server to use - REQUIRED $FromName = "Hermes" ; name from who the email was sent $FromAddress = "sender@gmail.com" ; address from where the mail should come $ToAddress = "recipient@gmail.com" ; destination address of the email - REQUIRED, use commas (,) to add more email addresses $Subject = "File not found" ; subject from the email - can be anything you want it to be $Body = "File not found!" ; the messagebody from the mail - can be left blank but then you get a blank mail $AttachFiles = "" ; the file(s) you want to attach seperated with a ; (Semicolon) - leave blank if not needed $CcAddress = "" ; address for cc - leave blank if not needed $BccAddress = "" ; address for bcc - leave blank if not needed $Importance = "High" ; Send message priority: "High", "Normal", "Low" $Username = "" ; username for the account used from where the mail gets sent - REQUIRED $Password = "" ; password for the account used from where the mail gets sent - REQUIRED $IPPort = 25 ; port used for sending the mail $ssl = 0 ; enables/disables secure socket layer sending - put to 1 if using httpS $tls = 0 ; enables/disables TLS when required Local $oAppl = _Excel_Open() Local $sWorkbook = "c:\test.xlsx" Local $oWorkbook = _Excel_BookOpen($oAppl, $sWorkbook) ;open excel and pass both parameters If FileExists($sWorkbook) Then ;Check if the file exist. Local $oAppl = _Excel_Open() Local $sWorkbook = "c:\test.xlsx" Local $oWorkbook = _Excel_BookOpen($oAppl, $sWorkbook) ;open excel and pass both parameters Local $aArray2 = _Excel_RangeRead($oWorkbook,Default,$oWorkbook.ActiveSheet.Usedrange.Columns("A:A")) Local $iIdx Local $Skipline = 0 ;0==> first line Do Local $temprf For $i = 0 To UBound($aArray2) - 1 $temprf &= $aArray2[$i] _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, ".//a[contains(@class,'edit') and contains(text(),'Edit')]") Local $aElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, ".//a[contains(@class,'edit') and contains(text(),'Edit')]", $sElement, True) $iIdx = _ArraySearch($aArray1, $aArray2[$i]) If @error Then ContinueLoop _WD_ElementAction($sSession, $aElement[$iIdx], 'click') If $i < $Skipline Then ContinueLoop $oRange = $oWorkbook.ActiveSheet.Range("B" & $i + 1 & ":XFD" & $i + 1) _Excel_RangeCopyPaste($oWorkbook.Activesheet, $oRange) ;Paste Local $oTest4 = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "pastebutton") _WD_ElementAction($sSession, $oTest4, 'click') Sleep(1000) ;Save Button Local $save3 = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "button.button") _WD_ElementAction($sSession, $save3, 'click') _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, "Completed", "B" & $i+1) sleep(1000) Next Until (Not @error) _Excel_Close($oWorkbook) Else _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl, $tls) Exit EndIf _WD_LoadWait($sSession) ;Attaching files to emails Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_CcAddress = "", $s_BccAddress = "", $s_Importance="Normal", $s_Username = "", $s_Password = "", $IPPort = 25, $ssl = 0, $tls = 0) Local $objEmail = ObjCreate("CDO.Message") $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>' $objEmail.To = $s_ToAddress Local $i_Error = 0 Local $i_Error_desciption = "" If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress If $s_BccAddress <> "" Then $objEmail.Bcc = $s_BccAddress $objEmail.Subject = $s_Subject If StringInStr($as_Body, "<") And StringInStr($as_Body, ">") Then $objEmail.HTMLBody = $as_Body Else $objEmail.Textbody = $as_Body & @CRLF EndIf $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer If Number($IPPort) = 0 then $IPPort = 25 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort ;Authenticated SMTP If $s_Username <> "" Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password EndIf ; Set security params If $ssl Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True If $tls Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendtls") = True ;Update settings $objEmail.Configuration.Fields.Update ; Set Email Importance Switch $s_Importance Case "High" $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "High" Case "Normal" $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Normal" Case "Low" $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Low" EndSwitch $objEmail.Fields.Update ; Sent the Message $objEmail.Send $objEmail="" EndFunc ;==>_INetSmtpMailCom Local $aDir = _FileListToArrayRec(@TempDir, "scoped_dir*;chrome_*", $FLTAR_FOLDERS, $FLTAR_NORECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH) Sleep(2000) For $i = 1 To $aDir[0] DirRemove($aDir[$i], $DIR_REMOVE) Next _WD_LoadWait($sSession) _WD_Shutdown() Func SetupChrome() _WD_Option('Driver', 'chromedriver.exe') _WD_Option('Port', 9515) _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["start-maximized","disable-infobars"]}}}}' EndFunc ;==>SetupChrome If the excel file doesn't exists in the folder, it will send an email to a specific recipient.
      What i am trying figure out now is if the excel crashes while the script/loop is running, I want to relaunch the excel file continue to the last row before the excel crashed. So if the value of column B is not marked as "completed", it should continue from that row
      Appreciate any help that I can get to achieve this.
      table1.html test.xlsx
    • By goku200
      I'm having some issues with my script that's not grabbing the id from the cell and appending it to the url test that I have in my script.
      Here is my script:
      #Include "wd_core.au3" #Include "wd_helper.au3" #Include "wd_core.au3" #Include "File.au3" #Include "Array.au3" #Include "Excel.au3" #Include "INet.au3" Local $sDesiredCapabilities, $sSession _WD_Startup() $Ssession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, "https://127.0.0.1/test.html?id=1");session is created. When tabed on browser it will populate url _WD_LoadWait($sSession) $someUser = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@name='username']") _WD_SetElementValue($sSession, $someUser, "test") $somePassword = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@name='password']") _WD_SetElementValue($sSession, $somePassword, "test") Local $aVar[1] _ArrayAdd ($aVar,_WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@type='submit'][@value='Sign in']")) _WD_ElementAction($sSession, $aVar[1], 'click') _WD_LoadWait($sSession) Local $oExcel = _Excel_Open() Local $oWorkbook = _Excel_BookOpen($oExcel, "C:\Users\<Username>\Downloads\test.xlsx") Local $aArray1 = _Excel_RangeRead($oExcel, 1) _ArrayDisplay($aArray1, "Vertical") For $i = 0 To UBound($aArray) - 1 WinActivate("[Class:Chrome]") $testLink = "https://127.0.0.1/test.html?id=" _WD_Navigate($sSession, $testLink) $aArray1 = ClipGet() _WD_NewTab($Ssession, clipPut($testLink), True) Send("{ENTER}") Local $test = InetGet($testLink + $aArray1, "C:\Users\<username>\Downloads\Test" & ".html") Send ("!s");save webpage as html Next Func SetupChrome() _WD_Option('Driver', 'chromedriver.exe') _WD_Option('Port', 9515) _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["start-maximized","disable-infobars"]}}}}' EndFunc ;==>SetupChrome What I'm having issues is looping through the id column in the excel spreadsheet and adding 1 to the url address when its tabbed by using _WD_NewTab. When it goes to the browser I'm wanting it to display: https://127.0.0.1/test.html?id=1 press Enter and save the file as 1.html and so forth for the others. Not sure what I'm doing wrong here. 
      test.xlsx
×
×
  • Create New...