CaptainBeardsEyesBeard Posted October 31, 2019 Share Posted October 31, 2019 hi All, Sorry for another post I am doing my first test for chrome I am trying to click an element as well as retrieve a value of an element expandcollapse popup_WD_Option('Driver', 'chromedriver.exe') _WD_Option('Port', 8080) _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true }}}}' CheckIfIEIsOpen($ApplicationWindow) Local Enum $eFireFox = 0, _ $eChrome, _ $eEdge Local Const $_TestType = $eChrome Local Const $sElementSelector = "//input[@name='q']" Local $sDesiredCapabilities Local $iIndex Local $sSession _WD_Startup() If @error <> $_WD_ERROR_Success Then Exit -1 EndIf $sSession = _WD_CreateSession($sDesiredCapabilities) ;/************************* Start URL**************************/ _ChromeStartup($IEURL,"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe") Sleep(10000) _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//*[@id='Welcome_c1_r0']/div[2]/perfect-scrollbar/div/div[1]/e3e-dashboard-process-panel/e3e-dashboard-link-farm/ul/li[5]/div/e3e-dashboard-link/div/a") ;MsgBox(0, "", "check for timeout") $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//*[@id='Welcome_c1_r0']/div[2]/perfect-scrollbar/div/div[1]/e3e-dashboard-process-panel/e3e-dashboard-link-farm/ul/li[5]/div/e3e-dashboard-link/div/a") $sText = _WD_ElementAction($sSession, $sElement, 'text') _WD_ElementAction($sSession, $sElement, 'click') if @error Then ConsoleWrite("Can't click Matter maintenance") Endif ConsoleWrite($sText) The main bit I guess is this bit of code but I posted full code above just in case _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//*[@id='Welcome_c1_r0']/div[2]/perfect-scrollbar/div/div[1]/e3e-dashboard-process-panel/e3e-dashboard-link-farm/ul/li[5]/div/e3e-dashboard-link/div/a") ;MsgBox(0, "", "check for timeout") $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//*[@id='Welcome_c1_r0']/div[2]/perfect-scrollbar/div/div[1]/e3e-dashboard-process-panel/e3e-dashboard-link-farm/ul/li[5]/div/e3e-dashboard-link/div/a") $sText = _WD_ElementAction($sSession, $sElement, 'text') _WD_ElementAction($sSession, $sElement, 'click') if @error Then ConsoleWrite("Can't click Matter maintenance") Endif ConsoleWrite($sText) MsgBox($MB_SYSTEMMODAL, "Test Result ", "Variable sElement equals " & $sText, 4) MsgBox($MB_SYSTEMMODAL, "Test Result ", "Variable sElement equals " & $sElement, 4) In this bit I'm trying to retrieve an element by xpath then retrieve the text I am also trying to click an element by xpath However whenever I run it the MsgBox is empty both times Link to comment Share on other sites More sharing options...
Danp2 Posted October 31, 2019 Share Posted October 31, 2019 @CaptainBeardsEyesBeard I feel like you are still trying to use the Chrome UDF along with the Webdriver UDF. Can't tell for sure because your script isn't able to run as posted (no #include lines, no navigation, etc). Please take some time to review and understand the included demo script and it's functionality. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
CaptainBeardsEyesBeard Posted October 31, 2019 Author Share Posted October 31, 2019 Ah OK I used this command _WD_Navigate($sSession, $IEURL) And it starts a CMD prompt but doesn't start a chrome window? Here's my full code this is the main file where I have my instances expandcollapse popup; Test includes #include "C:\AutomationTesting\Elite3eAutomation\Framework\Tests\Test1TestMainPage.au3" ;Generic functions #include "C:\AutomationTesting\Automation\GenericFunctions\GenericFunctions.au3" ;Web driver #include "C:\AutomationTesting\Automation\WebDriver\wd_core.au3" #include "C:\AutomationTesting\Automation\WebDriver\wd_helper.au3" ;#include "C:\AutomationTesting\Automation\WebDriver\wd_demo.au3" ;Json includes #include "C:\AutomationTesting\Automation\Json\Json.au3" #include "C:\AutomationTesting\Automation\Json\BinaryCall.au3" ;Winhttp includes #include "C:\AutomationTesting\Automation\WinHTTP\WinHttp.au3" #include "C:\AutomationTesting\Automation\WinHTTP\WinHttpConstants.au3" ;Chrome #include "C:\AutomationTesting\Automation\Chrome\Chrome.au3" ;Chrome Incdlues ;AutoIT includes7SO00s #include <FileConstants.au3> #include <WinAPIFiles.au3> #include <GuiConstantsEx.au3> #include <File.au3> #include <GuiComboBox.au3> #include <IE.au3> #include <SQLite.au3> #include <SQLite.dll.au3> #include <array.au3> Global $TestCount =1 $RandomClientNumber = 45 ;AutoItSetOption('MouseCoordMode', 0) AutoItSetOption('SendKeyDelay', 10) Global $ApplicationWindow = "appwindow" Global $IEURL = "http://weburl" if WinActivate($ApplicationWindow) then WinClose($ApplicationWindow) Else EndIf $TestResultstextLocation = "C:\Automation\Elite3eAutomation\Elie3eResults.txt" ; Open file - deleting any existing content Global $TestResults = FileOpen($TestResultstextLocation, $FO_OVERWRITE) $TestLogLocation = "C:\Automation\Elite3eAutomation\EliteLog.txt" ; Open file - deleting any existing content Global $TestLog = FileOpen($TestLogLocation, $FO_OVERWRITE) Sleep(4000) ;/******************************************************/ ;/*****************Main Program*************************/ ;/******************* ;intiialise Wd Test1TestMainPage($IEURL) _ChromeShutdown() FileClose($TestResultstextLocation) FileClose($TestLogLocation) MsgBox($MB_SYSTEMMODAL, "Testing Complete", "Testing complete. Please find the TestResults.TXT file at " & $TestResultstextLocation) and this is the function that is called expandcollapse popup;/********************************************************************************************/ ;/************************* Maximise screen***************************************************/ ;/********************************************************************************************/ Func Test1TestMainPage($IEURL) _WD_Option('Driver', 'chromedriver.exe') _WD_Option('Port', 8080) _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true }}}}' CheckIfIEIsOpen($ApplicationWindow) Local Enum $eFireFox = 0, _ $eChrome, _ $eEdge Local Const $_TestType = $eChrome Local Const $sElementSelector = "//input[@name='q']" Local $sDesiredCapabilities Local $iIndex Local $sSession _WD_Startup() If @error <> $_WD_ERROR_Success Then Exit -1 EndIf $sSession = _WD_CreateSession($sDesiredCapabilities) ;/************************* Start URL**************************/ _WD_Navigate($sSession, $IEURL) _WD_NewTab($sSession, True, -1, 'http://bing.com', 'width=200,height=200') WinActivate($ApplicationWindow) Sleep(10000) _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//*[@id='Welcome_c1_r0']/div[2]/perfect-scrollbar/div/div[1]/e3e-dashboard-process-panel/e3e-dashboard-link-farm/ul/li[5]/div/e3e-dashboard-link/div/a") ;MsgBox(0, "", "check for timeout") $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//*[@id='Welcome_c1_r0']/div[2]/perfect-scrollbar/div/div[1]/e3e-dashboard-process-panel/e3e-dashboard-link-farm/ul/li[5]/div/e3e-dashboard-link/div/a") $sText = _WD_ElementAction($sSession, $sElement, 'text') _WD_ElementAction($sSession, $sElement, 'click') if @error Then ConsoleWrite("Can't click Matter maintenance") Endif ConsoleWrite($sText) MsgBox($MB_SYSTEMMODAL, "Test Result ", "Variable sElement equals " & $sText, 4) MsgBox($MB_SYSTEMMODAL, "Test Result ", "Variable sElement equals " & $sElement, 4) if WinSetState($ApplicationWindow, "", @SW_MAXIMIZE) Then Else Sleep(6000) WinSetState($ApplicationWindow, "", @SW_MAXIMIZE) EndIf WinActivate($ApplicationWindow) ;/****************************End*************************************************************/ ;/****************************Test main page*********************************************/ _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//rect[@class='highcharts-button-box']") $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//rect[@class='highcharts-button-box']") If @error = $_WD_ERROR_NoMatch Then MsgBox(0, "", "No Match") EndIf _WD_ElementAction($sSession, $sElement, 'click') ;Check the following IDs and ensure they contain the correct word eg. 'Search' ;CheckAField_In_InternetExplorer_On_Inner_Text($contentID, "Anvil Proforma Generation", "Ensure Anvil Header field is showing correctly") EndFunc ;/********************************************************************************************/ ;/****************************End*************************************************************/ ;/********************************************************************************************/ Link to comment Share on other sites More sharing options...
Danp2 Posted October 31, 2019 Share Posted October 31, 2019 Several issues I can see -- You shouldn't be #including a bunch of those scripts (json, binarycall, winhttp, etc) because this isn't necessary. You shouldn't be #including the Chrome.au3 UDF in conjunction with the Webdriver UDF. Same goes for using the _Chrome* commands Port 8080 isn't the default port number for chromedriver.exe, so this is wrong unless you've taken additional steps to launch chromedriver with instructions to use the non-standard port number Again, I would implore you to take some time and run the demo script, dissect it's functionality so that you have a thorough understanding of the UDF functions. You can't expect us to continually correct these simple issues because you won't take the time to learn the basics on your own. 👌😉 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
CaptainBeardsEyesBeard Posted October 31, 2019 Author Share Posted October 31, 2019 Right but the demo doesn't even run beyond creating a black CMD screen. It doesn't produce a Chrome instance and go to the URL specified under _WD_Navigate($sSession, $IEURL) Link to comment Share on other sites More sharing options...
Danp2 Posted October 31, 2019 Share Posted October 31, 2019 Ok... let's stick with the demo script so that we are working with a known codebase. Please answer the following -- Have you made any changes, such as modifying the SetupChrome function so that it can find the chromedriver.exe console app? Is your Chrome.exe installed in the standard location? 1 hour ago, CaptainBeardsEyesBeard said: Right but the demo doesn't even run beyond creating a black CMD screen. I'm assuming this is the instance of chromedriver.exe that is being launched, which is expected behavior. Please confirm. Also, please post the complete results from the Scite output panel so that we can get a better idea on what is occurring. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
CaptainBeardsEyesBeard Posted November 4, 2019 Author Share Posted November 4, 2019 Yeah my chrome.exe is just under C:\Program Files (x86)\Google\Chrome\Application\chrome.exe and not made any changes. So my scite output is below but I never see a chrome window open expandcollapse popup>"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\AutomationTesting\Elite3eAutomation\Framework\TestEnv.au3" _WDStartup: OS: WIN_10 WIN32_NT 17134 _WDStartup: AutoIt: 3.3.14.4 _WDStartup: WD.au3: 0.1.0.21 _WDStartup: Driver: chromedriver.exe _WDStartup: Params: --log-path="C:\AutomationTesting\Elite3eAutomation\Framework\chrome.log" _WDStartup: Port: 8080 __WD_Post: URL=HTTP://127.0.0.1:8080/session; $sData={"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true }}}} __WD_Post: StatusCode=0; ResponseText=0 __WD_Post ==> Send / Recv error _WD_CreateSession: 0 _WD_CreateSession ==> Webdriver Exception: HTTP status = 0 __WD_Post: URL=HTTP://127.0.0.1:8080/session//url; $sData={"url":"http://testserver/testDB/web/ui/dashboard"} __WD_Post: StatusCode=0; ResponseText=0 __WD_Post ==> Send / Recv error _WD_Navigate: 0 _WD_Navigate ==> Webdriver Exception: HTTP status = 0 __WD_Post: URL=HTTP://127.0.0.1:8080/session//url; $sData={"url":"http://testserver/testDB/web/ui/dashboard"} __WD_Post: StatusCode=0; ResponseText=0 __WD_Post ==> Send / Recv error _WD_Navigate: 0 _WD_Navigate ==> Webdriver Exception: HTTP status = 0 __WD_Get: URL=HTTP://127.0.0.1:8080/session//window/handles __WD_Get: StatusCode=0; $iResult = 5; $sResponseText=0... __WD_Get ==> Send / Recv error _WD_Window: 0... _WD_Window ==> Webdriver Exception: HTTP status = 0 _WD_Attach ==> General Error __WD_Post: URL=HTTP://127.0.0.1:8080/session//element; $sData={"using":"xpath","value":"//*[@id='Welcome_c1_r0']/div[2]/perfect-scrollbar/div/div[1]/e3e-dashboard-process-panel/e3e-dashboard-link-farm/ul/li[5]/div/e3e-dashboard-link/div/a"} __WD_Post: StatusCode=0; ResponseText=0 __WD_Post ==> Send / Recv error _WD_FindElement: 0 _WD_FindElement ==> Send / Recv error: HTTP status = 0 __WD_Post: URL=HTTP://127.0.0.1:8080/session//element; $sData={"using":"xpath","value":"//*[@id='Welcome_c1_r0']/div[2]/perfect-scrollbar/div/div[1]/e3e-dashboard-process-panel/e3e-dashboard-link-farm/ul/li[5]/div/e3e-dashboard-link/div/a"} __WD_Post: StatusCode=0; ResponseText=0 __WD_Post ==> Send / Recv error _WD_FindElement: 0 _WD_FindElement ==> Send / Recv error: HTTP status = 0 __WD_Post: URL=HTTP://127.0.0.1:8080/session//element; $sData={"using":"xpath","value":"//*[@id='Welcome_c1_r0']/div[2]/perfect-scrollbar/div/div[1]/e3e-dashboard-process-panel/e3e-dashboard-link-farm/ul/li[5]/div/e3e-dashboard-link/div/a"} __WD_Post: StatusCode=0; ResponseText=0 __WD_Post ==> Send / Recv error _WD_FindElement: 0 _WD_FindElement ==> Send / Recv error: HTTP status = 0 __WD_Post: URL=HTTP://127.0.0.1:8080/session//element; $sData={"using":"xpath","value":"//*[@id='Welcome_c1_r0']/div[2]/perfect-scrollbar/div/div[1]/e3e-dashboard-process-panel/e3e-dashboard-link-farm/ul/li[5]/div/e3e-dashboard-link/div/a"} __WD_Post: StatusCode=0; ResponseText=0 __WD_Post ==> Send / Recv error _WD_FindElement: 0 _WD_FindElement ==> Send / Recv error: HTTP status = 0 __WD_Post: URL=HTTP://127.0.0.1:8080/session//element; $sData={"using":"xpath","value":"//*[@id='Welcome_c1_r0']/div[2]/perfect-scrollbar/div/div[1]/e3e-dashboard-process-panel/e3e-dashboard-link-farm/ul/li[5]/div/e3e-dashboard-link/div/a"} __WD_Post: StatusCode=0; ResponseText=0 __WD_Post ==> Send / Recv error _WD_FindElement: 0 _WD_FindElement ==> Send / Recv error: HTTP status = 0 __WD_Post: URL=HTTP://127.0.0.1:8080/session//element; $sData={"using":"xpath","value":"//*[@id='Welcome_c1_r0']/div[2]/perfect-scrollbar/div/div[1]/e3e-dashboard-process-panel/e3e-dashboard-link-farm/ul/li[5]/div/e3e-dashboard-link/div/a"} __WD_Post: StatusCode=0; ResponseText=0 __WD_Post ==> Send / Recv error _WD_FindElement: 0 _WD_FindElement ==> Send / Recv error: HTTP status = 0 _WD_WaitElement ==> Timeout __WD_Post: URL=HTTP://127.0.0.1:8080/session//element; $sData={"using":"xpath","value":"//*[@id='Welcome_c1_r0']/div[2]/perfect-scrollbar/div/div[1]/e3e-dashboard-process-panel/e3e-dashboard-link-farm/ul/li[5]/div/e3e-dashboard-link/div/a"} __WD_Post: StatusCode=0; ResponseText=0 __WD_Post ==> Send / Recv error _WD_FindElement: 0 _WD_FindElement ==> Send / Recv error: HTTP status = 0 __WD_Get: URL=HTTP://127.0.0.1:8080/session//element//text __WD_Get: StatusCode=0; $iResult = 5; $sResponseText=0... __WD_Get ==> Send / Recv error _WD_ElementAction: 0... _WD_ElementAction ==> Send / Recv error __WD_Post: URL=HTTP://127.0.0.1:8080/session//element//click; $sData={"id":""} __WD_Post: StatusCode=0; ResponseText=0 __WD_Post ==> Send / Recv error _WD_ElementAction: 0... _WD_ElementAction ==> Send / Recv error Can't click Matter maintenance__WD_Post: URL=HTTP://127.0.0.1:8080/session//element; $sData={"using":"xpath","value":"//rect[@class='highcharts-button-box']"} __WD_Post: StatusCode=0; ResponseText=0 __WD_Post ==> Send / Recv error _WD_FindElement: 0 _WD_FindElement ==> Send / Recv error: HTTP status = 0 __WD_Post: URL=HTTP://127.0.0.1:8080/session//element; $sData={"using":"xpath","value":"//rect[@class='highcharts-button-box']"} __WD_Post: StatusCode=0; ResponseText=0 __WD_Post ==> Send / Recv error _WD_FindElement: 0 _WD_FindElement ==> Send / Recv error: HTTP status = 0 __WD_Post: URL=HTTP://127.0.0.1:8080/session//element; $sData={"using":"xpath","value":"//rect[@class='highcharts-button-box']"} __WD_Post: StatusCode=0; ResponseText=0 __WD_Post ==> Send / Recv error _WD_FindElement: 0 _WD_FindElement ==> Send / Recv error: HTTP status = 0 __WD_Post: URL=HTTP://127.0.0.1:8080/session//element; $sData={"using":"xpath","value":"//rect[@class='highcharts-button-box']"} __WD_Post: StatusCode=0; ResponseText=0 __WD_Post ==> Send / Recv error _WD_FindElement: 0 _WD_FindElement ==> Send / Recv error: HTTP status = 0 __WD_Post: URL=HTTP://127.0.0.1:8080/session//element; $sData={"using":"xpath","value":"//rect[@class='highcharts-button-box']"} __WD_Post: StatusCode=0; ResponseText=0 __WD_Post ==> Send / Recv error _WD_FindElement: 0 _WD_FindElement ==> Send / Recv error: HTTP status = 0 __WD_Post: URL=HTTP://127.0.0.1:8080/session//element; $sData={"using":"xpath","value":"//rect[@class='highcharts-button-box']"} __WD_Post: StatusCode=0; ResponseText=0 __WD_Post ==> Send / Recv error _WD_FindElement: 0 _WD_FindElement ==> Send / Recv error: HTTP status = 0 _WD_WaitElement ==> Timeout __WD_Post: URL=HTTP://127.0.0.1:8080/session//element; $sData={"using":"xpath","value":"//rect[@class='highcharts-button-box']"} __WD_Post: StatusCode=0; ResponseText=0 __WD_Post ==> Send / Recv error _WD_FindElement: 0 _WD_FindElement ==> Send / Recv error: HTTP status = 0 __WD_Post: URL=HTTP://127.0.0.1:8080/session//element//click; $sData={"id":""} __WD_Post: StatusCode=0; ResponseText=0 __WD_Post ==> Send / Recv error _WD_ElementAction: 0... _WD_ElementAction ==> Send / Recv error >Exit code: 0 Time: 61.57 Link to comment Share on other sites More sharing options...
Danp2 Posted November 4, 2019 Share Posted November 4, 2019 3 hours ago, CaptainBeardsEyesBeard said: _WDStartup: Port: 8080 On 10/31/2019 at 10:53 AM, Danp2 said: Port 8080 isn't the default port number for chromedriver.exe, so this is wrong unless you've taken additional steps to launch chromedriver with instructions to use the non-standard port number Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now