Jump to content

Chrome Webdriver - No Break Space   " "


Go to solution Solved by mLipok,

Recommended Posts

How should I be attempting to click this link?

image.png.31a0606191612d39c9063a9d3e63268c.png

<span id="x2m8_R-s" class="s_22 s-text">Walk&nbsp;In</span>

If I double click the Walk$nbsp;In the text reads Walk In.

image.png.d3e2aa589cd5c136349a9a9e1c1b6c8f.png

How can I search for this text? 

I have tried a several  different ways with no luck. Here are a few;

$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '//span[text()="Walk${nbsp}In"]')


$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//span[translate(text(), '\u00a0', ' ') = 'Walk In']")


$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//span[contains(text(),'Walk In')]")


$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//span[contains(text(),'Walk&nbsp;In')]")

Any help is appreciated as always. 

 

 

 

Edited by SkysLastChance

Life's simple. You make choices and you don't look back.

Link to post
Share on other sites
  • SkysLastChance changed the title to Chrome Webdriver - No Break Space   " "
  • Solution

Try this

$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//span[contains(text(),'Walk" & Chr(160) & "In')]")

btw.
why you are not using ID ?

$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//span[@id='x2m8_R-s']")

 

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 * for other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2021-10-18

Link to post
Share on other sites
15 hours ago, mLipok said:

Try this

$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//span[contains(text(),'Walk" & Chr(160) & "In')]")

 

Is it working ?

EDIT: 
I see now.

9 minutes ago, SkysLastChance said:

The first method did work. 

Thanks

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 * for other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2021-10-18

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

    No registered users viewing this page.

  • Similar Content

    • By goku200
      I'm having an issue with my html paginated table. The script work as expected. It reads the html table and clicks on the Download button. However when it clicks on the next page its not iterating the items. instead it goes to the next URL from the spreadsheet and then iterates through the html table clicking the Download button and so on. Not sure why its doing that. I want it to click the next page and then continue iterating then after it has reached the end of the pagination go to the next url in the spreadsheet and repeat the process. Below is my script. Any help is appreciated 🙂
      HTML Table:
      <!doctype html> <html> <head> <meta charset="utf-8"> <title>Test</title> </head> <body> <span style="font-weight:bold; font-size:13px">12345</span> <table width="100%" cellspacing="0" cellpadding="0" border="0"> <tbody><tr> <td> <table width="100%" cellspacing="1" cellpadding="2" border="0"> <tbody> <tr> <td class="test">ID</td> <td class="test" width="100%" nowrap=""> Name</td> <td class="test" nowrap="">Test1 Name</td> <td class="test" nowrap="">Test Date</td> <td class="test" nowrap="">Test Default</td> <td class="test" nowrap="">Test Status</td> <td class="test" nowrap="">Test Format</td> <td class="test" colspan="4">Actions&nbsp;</td> </tr> <tr> <td class="test" align="center">1</td> <td class="test">Test1</td> <td class="test" nowrap="">Joe</td> <td class="test" nowrap="">1/19/2022</td> <td class="test" nowrap=""> Default </td> <td class="test" nowrap=""> Uploaded </td> <td class="test" nowrap=""> html </td> <td class="test"><a href="#Download1">Download</a></td> </tr> <tr> <td class="test" align="center">2</td> <td class="test">Test2</td> <td class="test" nowrap="">Joe</td> <td class="test" nowrap="">1/19/2022</td> <td class="test" nowrap=""> Default </td> <td class="test" nowrap=""> Uploaded </td> <td class="test" nowrap=""> html </td> <td class="test"><a href="#Download2">Download</a></td> </tr> <tr> <td class="test" align="center">3</td> <td class="test">Test3</td> <td class="test" nowrap="">Joe</td> <td class="test" nowrap="">1/19/2022</td> <td class="test" nowrap=""> Default </td> <td class="test" nowrap=""> Uploaded </td> <td class="test" nowrap=""> html </td> <td class="test"><a href="#Download3">Download</a></td> </tr> <tr> <td class="test" align="center">4</td> <td class="test">Test4</td> <td class="test" nowrap="">Joe</td> <td class="test" nowrap="">1/19/2022 </td> <td class="test" nowrap=""> Default </td> <td class="test" nowrap=""> Uploaded </td> <td class="test" nowrap=""> html </td> <td class="test"><a href="#Download4">Download</a></td> </tr> <tr> <td class="test" align="center">5</td> <td class="test">Test5</td> <td class="test" nowrap="">Joe</td> <td class="test" nowrap="">1/19/2022</td> <td class="test" nowrap=""> Default </td> <td class="test" nowrap=""> Uploaded </td> <td class="test" nowrap=""> html </td> <td class="test"><a href="#Download5">Download</a></td> </tr> <tr> <td class="test" align="center">6</td> <td class="test">Test6</td> <td class="test" nowrap="">Joe</td> <td class="test" nowrap="">1/19/2022</td> <td class="test" nowrap=""> Default </td> <td class="test" nowrap=""> Uploaded </td> <td class="test" nowrap=""> html </td> <td class="test"><a href="#Download6">Download</a></td> </tr> <tr> <td class="test" align="center">7</td> <td class="test">Test7</td> <td class="test" nowrap="">Joe</td> <td class="test" nowrap="">1/19/2022</td> <td class="test" nowrap=""> Default </td> <td class="test" nowrap=""> Uploaded </td> <td class="test" nowrap=""> html </td> <td class="test"><a href="#Download7">Download</a></td> </tr> <tr> <td class="test" align="center">8</td> <td class="test">Test8</td> <td class="test" nowrap="">Joe</td> <td class="test" nowrap="">1/19/2022</td> <td class="test" nowrap=""> Default </td> <td class="test" nowrap=""> Uploaded </td> <td class="test" nowrap=""> html </td> <td class="test"><a href="#Download8">Download</a></td> </tr> <tr> <td class="test" align="center">9</td> <td class="test">Test9</td> <td class="test" nowrap="">Joe</td> <td class="test" nowrap="">1/7/2022</td> <td class="test" nowrap=""> Default </td> <td class="test" nowrap=""> Uploaded </td> <td class="test" nowrap=""> html </td> <td class="test"><a href="#Download9">Download</a></td> </tr> <tr> <td class="test" align="center">10</td> <td class="test">Test10</td> <td class="test" nowrap="">Joe</td> <td class="test" nowrap="">12/8/2021</td> <td class="test" nowrap=""> Default </td> <td class="test" nowrap=""> Uploaded </td> <td class="test" nowrap=""> html </td> <td class="test"><a href="#Download10">Download</a></td> </tr> <tr> <td class="test" align="center">11</td> <td class="test">Test11</td> <td class="test" nowrap="">Joe</td> <td class="test" nowrap="">12/5/2021</td> <td class="test" nowrap=""> Default </td> <td class="test" nowrap=""> Uploaded </td> <td class="test" nowrap=""> html </td> <td class="test"><a href="#Download11">Download</a></td> </tr> <tr> <td class="test" align="center">12</td> <td class="test">Test12</td> <td class="test" nowrap="">Joe</td> <td class="test" nowrap="">12/5/2021</td> <td class="test" nowrap=""> Default </td> <td class="test" nowrap=""> Uploaded </td> <td class="test" nowrap=""> html </td> <td class="test"><a href="#Download12">Download</a></td> </tr> <tr> <td class="test" align="center">13</td> <td class="test">Test13</td> <td class="test" nowrap="">Joe</td> <td class="test" nowrap="">12/5/2021</td> <td class="test" nowrap=""> Default </td> <td class="test" nowrap=""> Uploaded </td> <td class="test" nowrap=""> html </td> <td class="test"><a href="#Download13">Download</a></td> </tr> <tr> <td class="test" align="center">14</td> <td class="test">Test14</td> <td class="test" nowrap="">Joe</td> <td class="test" nowrap="">11/29/2021</td> <td class="test" nowrap=""> Default </td> <td class="test" nowrap=""> Uploaded </td> <td class="test" nowrap=""> html </td> <td class="test"><a href="#Download14">Download</a></td> </tr> <tr> <td class="test" align="center">15</td> <td class="test">Test15</td> <td class="test" nowrap="">Joe</td> <td class="test" nowrap="">11/29/2021</td> <td class="test" nowrap=""> Default </td> <td class="test" nowrap=""> Uploaded </td> <td class="test" nowrap=""> html </td> <td class="test"><a href="#Download15">Download</a></td> </tr> <tr> <td class="test" align="center">16</td> <td class="test">Test16</td> <td class="test" nowrap="">Joe</td> <td class="test" nowrap="">11/29/2021</td> <td class="test" nowrap=""> Default </td> <td class="test" nowrap=""> Uploaded </td> <td class="test" nowrap=""> html </td> <td class="test"><a href="#Download16">Download</a></td> </tr> <tr> <td class="test" align="center">17</td> <td class="test">Test17</td> <td class="test" nowrap="">Joe</td> <td class="test" nowrap="">11/29/2021</td> <td class="test" nowrap=""> Default </td> <td class="test" nowrap=""> Uploaded </td> <td class="test" nowrap=""> html </td> <td class="test"><a href="#Download17">Download</a></td> </tr> <tr> <td class="test" align="center">18</td> <td class="test">Test18</td> <td class="test" nowrap="">Joe</td> <td class="test" nowrap="">11/29/2021</td> <td class="test" nowrap=""> Default </td> <td class="test" nowrap=""> Uploaded </td> <td class="test" nowrap=""> html </td> <td class="test"><a href="#Download18">Download</a></td> </tr> <tr> <td class="test" align="center">19</td> <td class="test">Test19</td> <td class="test" nowrap="">Joe</td> <td class="test" nowrap="">11/29/2021</td> <td class="test" nowrap=""> Default </td> <td class="test" nowrap=""> Uploaded </td> <td class="test" nowrap=""> html </td> <td class="test"><a href="#Download19">Download</a></td> </tr> <tr> <td class="test" align="center">20</td> <td class="test">Test20</td> <td class="test" nowrap="">Joe</td> <td class="test" nowrap="">11/29/2021</td> <td class="test" nowrap=""> Default </td> <td class="test" nowrap=""> Uploaded </td> <td class="test" nowrap=""> html </td> <td class="test"><a href="#Download20">Download</a></td> </tr> <tr> <td class="test" align="center">21</td> <td class="test">Test21</td> <td class="test" nowrap="">Joe</td> <td class="test" nowrap="">11/29/2021</td> <td class="test" nowrap=""> Default </td> <td class="test" nowrap=""> Uploaded </td> <td class="test" nowrap=""> html </td> <td class="test"><a href="#Download21">Download</a></td> </tr> <tr> <td class="test" align="center">22</td> <td class="test">Test22</td> <td class="test" nowrap="">Joe</td> <td class="test" nowrap="">11/29/2021</td> <td class="test" nowrap=""> Default </td> <td class="test" nowrap=""> Uploaded </td> <td class="test" nowrap=""> html </td> <td class="test"><a href="#Download22">Download</a></td> </tr> <tr> <td class="test" align="center">23</td> <td class="test">Test23</td> <td class="test" nowrap="">Joe</td> <td class="test" nowrap="">11/29/2021</td> <td class="test" nowrap=""> Default </td> <td class="test" nowrap=""> Uploaded </td> <td class="test" nowrap=""> html </td> <td class="test"><a href="#Download23">Download</a></td> </tr> <tr> <td class="test" align="center">24</td> <td class="test">Test24</td> <td class="test" nowrap="">Joe</td> <td class="test" nowrap="">11/29/2021</td> <td class="test" nowrap=""> Default </td> <td class="test" nowrap=""> Uploaded </td> <td class="test" nowrap=""> html </td> <td class="test"><a href="#Download24">Download</a></td> </tr> <tr> <td class="test" align="center">25</td> <td class="test">Test25</td> <td class="test" nowrap="">Joe</td> <td class="test" nowrap="">11/29/2021</td> <td class="test" nowrap=""> Default </td> <td class="test" nowrap=""> Uploaded </td> <td class="test" nowrap=""> html </td> <td class="test"><a href="#Download25">Download</a></td> </tr> </tbody></table> </td></tr> </tbody></table> <table cellspacing="1" cellpadding="3" border="0"> <tbody><tr> <td valign="middle"> </td> <td valign="middle"> <select name="next"> <option value="1" selected="">Page 1 of 7 </option><option value="2">Page 2 of 7 </option><option value="3">Page 3 of 7 </option><option value="4">Page 4 of 7 </option><option value="5">Page 5 of 7 </option><option value="6">Page 6 of 7 </option><option value="7">Page 7 of 7 </option></select> </td> <td valign="middle"> <a href="Next">Next</a> </td> </tr> </tbody></table> </body> </html> Autoit script
      #Include "wd_core.au3" #Include "wd_helper.au3" #Include "WinHttp.au3" #include <MsgBoxConstants.au3> #include <File.au3> #include <AutoItConstants.au3> #include <WinAPIFiles.au3> #include <Array.au3> #include <Excel.au3> Local $sDesiredCapabilities, $sSession SetupChrome() _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_LoadWait($sSession) Sleep(5000) _WD_LoadWait($sSession) Sleep(5000) _WD_Navigate($sSession, '') _WD_LoadWait($sSession) _WD_NewTab($sSession) $ArticleWindow = _WD_Window($sSession, 'window', '') _WD_LoadWait($sSession) sleep(5000) _ExcelFunction() Func _ExcelFunction() Local $oAppl = _Excel_Open() Local $sWorkbook = "C:\Users\<username here>\Downloads\table.xlsx" Local $oWorkbook = _Excel_BookOpen($oAppl, $sWorkbook) Local $aArray2 = _Excel_RangeRead($oWorkbook,Default,$oWorkbook.ActiveSheet.Usedrange.Columns("A:A")) For $i = 0 To UBound($aArray2) - 1 ;Skip from reading header columns Local $Skipline = 1 ;0==> first line Local $temprf $temprf &= $aArray2[$i] If @error Then ContinueLoop If $i < $Skipline Then ContinueLoop _WD_Window($sSession, 'Switch', '{"handle":"' & $ArticleWindow & '"}') sleep(500) _WD_Navigate($sSession, $aArray2[$i]) _WD_LoadWait($sSession) Sleep(2000) htmlTable() Next EndFunc Func htmlTable() $sTable = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//html/body/table[1]/tbody/tr/td/table") _WD_HighlightElement($sSession, $sTable, 2) _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//html/body/table[1]/tbody/tr/td/table/tbody") Local $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//html/body/table[1]/tbody/tr/td/table/tbody") Local $aArray1 = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, ".//td[8]/a", $sElement, True) For $i = 0 to UBound($aArray1) - 1 $aArray1[$i] = _WD_ElementAction($sSession, $aArray1[$i], 'text') Next _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//html/body/table[1]/tbody/tr/td/table/tbody") Local $sElement1 = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//html/body/table[1]/tbody/tr/td/table/tbody") Local $aArray11 = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, ".//td[1]", $sElement1, True) For $j = 0 to UBound($aArray11) - 1 ;Skip from reading header columns Local $Skipline = 0 ;0==> first line Local $temprf $temprf &= $aArray11[$j] If @error Then ContinueLoop If $j < $Skipline Then ContinueLoop $aArray11[$j] = _WD_ElementAction($sSession, $aArray11[$j], 'text') Next ;Finds the ID and places it in a variable Local $sElement10 = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//html/body/span") $sValue = _WD_ElementAction($sSession, $sElement10, 'text') ;Finds the ID and places it in a variable Local $sElement11 = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, ".//td[1]") $sValue2 = _WD_ElementAction($sSession, $sElement11, 'text') For $i = 0 to UBound($aArray1) - 1 ;Find the table of all the IDs $sButton1 = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//html/body/table[1]/tbody/tr/td/table") _WD_HighlightElement($sSession, $sButton1, 2) _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//html/body/table[1]/tbody/tr/td/table/tbody") Local $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//html/body/table[1]/tbody/tr/td/table/tbody") Local $aArray1 = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, ".//td[8]/a", $sElement, True) _WD_HighlightElement($sSession, $aArray1, 2) $links = _WD_ElementAction($sSession, $aArray1[$i], 'click') Sleep(2000) FileMove('C:\Users\<username here>\Downloads\*.html', 'C:\Users\<username here>\Downloads\' & $sValue & "_r" & $aArray11[$i] & '.htm', 1) Next ;Click on Next Page Local $next = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//html/body/table[2]/tbody/tr/td[3]/a") _WD_ElementAction($sSession, $next, 'click') Sleep(2000) EndFunc _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": {"debuggerAddress": "localhost:9222"} {"w3c": true, "args":["start-maximized","disable-infobars"]}}}}' EndFunc  
    • By Danp2
      Introduction
      This UDF will allow you to interact with any browser that supports the W3C WebDriver specifications. Supporting multiple browsers via the same code base is now possible with just a few configuration settings.
      Requirements
      JSON UDF https://www.autoitscript.com/forum/topic/148114-a-non-strict-json-udf-jsmn
      WinHTTP UDF https://www.autoitscript.com/forum/topic/84133-winhttp-functions/
      HtmlTable2Array UDF (optional) https://www.autoitscript.com/forum/topic/167679-read-data-from-html-tables-from-raw-html-source/
      WebDriver for desired browser
      Chrome WebDriver https://sites.google.com/a/chromium.org/chromedriver/downloads FireFox WebDriver https://github.com/mozilla/geckodriver/releases Edge WebDriver https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/ Source Code
      You will always be able to find the latest version in the GitHub Repo 
      Help / Support
      See the wiki for details on the UDF --
      https://www.autoitscript.com/wiki/WebDriver
      Please post any questions, suggestions or errors in the GH&S thread.
      https://www.autoitscript.com/forum/topic/205553-webdriver-udf-help-support-iii/
      Previous support threads (Closed)
      https://www.autoitscript.com/forum/topic/192730-webdriver-udf-help-support/
      https://www.autoitscript.com/forum/topic/201106-webdriver-udf-help-support-ii/
       
    • By mLipok
      wd_capabilities.au3 UDF was changed/modified/refactored .... and commited/merged (02-12-2021) to https://github.com/Danp2/WebDriver

      WARNING: Before you start using this UDF be sure you download the recent version from: https://github.com/Danp2/WebDriver
       
      ==================================================================================================

      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
      Hi, I am trying to select elements in print page (dialog window) for a specific web page. But when trying to do so, it looks like it does not allow me to do it.
      So far, this is what I have:
      _WD_WaitElement($sSession, $_WD_LOCATOR_ByCSSSelector, "body") Local $mainpagebody = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "body") _WD_HighlightElement($sSession, $mainpagebody, 2) _WD_WaitElement($sSession, $_WD_LOCATOR_ByCSSSelector, "img.print-button") Local $printbutton = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "img.print-button") _WD_ElementAction($sSession, $printbutton, 'click') _WD_LoadWait($sSession) Sleep(3000) _WD_WaitElement($sSession, $_WD_LOCATOR_ByCSSSelector, "body") Local $printpagebody = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "body") _WD_HighlightElement($sSession, $printpagebody, 2) The script above highlights the main web page "body" element, then clicks a tag to print a specific part of the page, then it will open a print page window where i am trying to highlight the body of that print page - but it looks like it is dropping from the session because it opens up another chrome page chrome://print.
       
      Below is the output log:
      __WD_Post: URL=HTTP://127.0.0.1:9515/session/cd08704233a965ccbaf9292e8692c3e4/element; $sData={"using":"css selector","value":"body"} __WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"91a394f0-004c-480d-aedf-52e2b30233c6"}}... _WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"91a394f0-004c-480d-aedf-52e2b30233c6"}} _WD_WaitElement ==> Success __WD_Post: URL=HTTP://127.0.0.1:9515/session/cd08704233a965ccbaf9292e8692c3e4/element; $sData={"using":"css selector","value":"body"} __WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"91a394f0-004c-480d-aedf-52e2b30233c6"}}... _WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"91a394f0-004c-480d-aedf-52e2b30233c6"}} __WD_Post: URL=HTTP://127.0.0.1:9515/session/cd08704233a965ccbaf9292e8692c3e4/execute/sync; $sData={"script":"arguments[0].style='background: #FFFF66; border-radius: 5px; padding-left: 3px;'; return true;", "args":[{"element-6066-11e4-a52e-4f735466cecf":"91a394f0-004c-480d-aedf-52e2b30233c6"}]} __WD_Post: StatusCode=200; ResponseText={"value":true}... _WD_ExecuteScript: {"value":true}... __WD_Post: URL=HTTP://127.0.0.1:9515/session/cd08704233a965ccbaf9292e8692c3e4/element; $sData={"using":"css selector","value":"img.print-link"} __WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"eb9e4673-4dec-4d4c-be6a-b7967743394b"}}... _WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"eb9e4673-4dec-4d4c-be6a-b7967743394b"}} _WD_WaitElement ==> Success __WD_Post: URL=HTTP://127.0.0.1:9515/session/cd08704233a965ccbaf9292e8692c3e4/element; $sData={"using":"css selector","value":"img.print-link"} __WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"eb9e4673-4dec-4d4c-be6a-b7967743394b"}}... _WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"eb9e4673-4dec-4d4c-be6a-b7967743394b"}} __WD_Post: URL=HTTP://127.0.0.1:9515/session/cd08704233a965ccbaf9292e8692c3e4/element/eb9e4673-4dec-4d4c-be6a-b7967743394b/click; $sData={"id":"eb9e4673-4dec-4d4c-be6a-b7967743394b"} __WD_Post: StatusCode=200; ResponseText={"value":null}... _WD_ElementAction: {"value":null}... __WD_Post: URL=HTTP://127.0.0.1:9515/session/cd08704233a965ccbaf9292e8692c3e4/execute/sync; $sData={"script":"arguments[0].style='background: #FFFF66; border-radius: 5px; padding-left: 3px;'; return true;", "args":[{"element-6066-11e4-a52e-4f735466cecf":"eb9e4673-4dec-4d4c-be6a-b7967743394b"}]} __WD_Post: StatusCode=200; ResponseText={"value":true}... _WD_ExecuteScript: {"value":true}... __WD_Post: URL=HTTP://127.0.0.1:9515/session/cd08704233a965ccbaf9292e8692c3e4/execute/sync; $sData={"script":"return document.readyState", "args":[]} __WD_Post: StatusCode=500; ResponseText={"value":{"error":"script timeout","message":"script timeout\n (Session info: chrome=92.0.4515.107)... __WD_Post ==> Webdriver Exception: {"value":{"error":"script timeout","message":"script timeout\n (Session info: chrome=92.0.4515.107)","stacktrace":"Backtrace:\n\tOrdinal0 [0x00C63733+2504499]\n\tOrdinal0 [0x00BFC401+2081793]\n\tOrdinal0 [0x00B024F0+1058032]\n\tOrdinal0 [0x00B55685+1398405]\n\tOrdinal0 [0x00B45E83+1334915]\n\tOrdinal0 [0x00B54CDB+1395931]\n\tOrdinal0 [0x00B45D4B+1334603]\n\tOrdinal0 [0x00B222B4+1188532]\n\tOrdinal0 [0x00B23149+1192265]\n\tGetHandleVerifier [0x00DDFB8C+1512252]\n\tGetHandleVerifier [0x00E8B0DF+2214031]\n\tGetHandleVerifier [0x00CE4BC3+484211]\n\tGetHandleVerifier [0x00CE3E69+480793]\n\tOrdinal0 [0x00C0218D+2105741]\n\tOrdinal0 [0x00C066E8+2123496]\n\tOrdinal0 [0x00C06827+2123815]\n\tOrdinal0 [0x00C0FB73+2161523]\n\tBaseThreadInitThunk [0x75EB62C4+36]\n\tRtlSubscribeWnfStateChangeNotification [0x77C11B69+1081]\n\tRtlSubscribeWnfStateChangeNotification [0x77C11B34+1028]\n"}} _WD_ExecuteScript: {"value":{"error":"script timeout","message":"script timeout\n (Session info: chrome=92.0.4515.107)... _WD_ExecuteScript ==> Webdriver Exception: HTTP status = 500 _WD_LoadWait ==> Webdriver Exception __WD_Post: URL=HTTP://127.0.0.1:9515/session/cd08704233a965ccbaf9292e8692c3e4/element; $sData={"using":"css selector","value":"body"} __WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"91a394f0-004c-480d-aedf-52e2b30233c6"}}... _WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"91a394f0-004c-480d-aedf-52e2b30233c6"}} _WD_WaitElement ==> Success __WD_Post: URL=HTTP://127.0.0.1:9515/session/cd08704233a965ccbaf9292e8692c3e4/element; $sData={"using":"css selector","value":"body"} __WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"91a394f0-004c-480d-aedf-52e2b30233c6"}}... _WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"91a394f0-004c-480d-aedf-52e2b30233c6"}} __WD_Post: URL=HTTP://127.0.0.1:9515/session/cd08704233a965ccbaf9292e8692c3e4/execute/sync; $sData={"script":"arguments[0].style='background: #FFFF66; border-radius: 5px; padding-left: 3px;'; return true;", "args":[{"element-6066-11e4-a52e-4f735466cecf":"91a394f0-004c-480d-aedf-52e2b30233c6"}]} __WD_Post: StatusCode=200; ResponseText={"value":true}... _WD_ExecuteScript: {"value":true}...  
      Is it even possible to select elements in print page?

    • 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
×
×
  • Create New...