Jump to content

Setting a field in WebDriver UDF in Chrome


Recommended Posts

Hi 

 

I'm wondering why I cannot set this field in Chrome WebDriver 

$SearchXpath = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '//*[@id="GenSearchContainer"]/div/input[1]')
   _WD_ElementAction($sSession, $SearchXpath, 'value', "553625")

Full Script is here (I was having trouble clicking by using the XPath so resorted to mouseclicks 

_WD_Navigate($sSession, $PaperlessURL)

         $ApplicationWindow = "Application window"

         Sleep(10000)
         WinActivate($ApplicationWindow)
         Local $hWnd = WinWait($ApplicationWindow, "", 10)
         WinSetState($hWnd, "", @SW_MAXIMIZE )

         MsgBox(64, "", "Input user and password Then click OK when done")

   Sleep(3000)
         MouseClick($MOUSE_CLICK_LEFT, 34, 544, 1)

         Sleep(5000)
    Sleep(12000)
    Msgbox(64, "", "waiting for click",5)
         MouseClick($MOUSE_CLICK_LEFT, 33, 538, 1)
         Sleep(5000)
         MouseClick($MOUSE_CLICK_LEFT, 328, 508, 1)

   Sleep(15000)
    $SearchXpath = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '//*[@id="GenSearchContainer"]/div/input[1]')
   _WD_ElementAction($sSession, $SearchXpath, 'value', "553625")

 

I get the xpath by right clicking the blue highlighted bit of the html

 

image.png.1e9dfb5bb8af9465295defd884d1f718.png

 

My Console out put is

_WDStartup: OS: WIN_10 WIN32_NT 18363 
_WDStartup: AutoIt: 3.3.14.4
_WDStartup: WD.au3: 0.2.0.5
_WDStartup: WinHTTP:    1.6.4.1
_WDStartup: Driver: chromedriver.exe
_WDStartup: Params: --log-path="H:\Quality Assurance\AutoIT Scripts\ElitePaperless\Framework\chrome.log"
_WDStartup: Port:   9515
__WD_Post: URL=HTTP://127.0.0.1:9515/session; $sData={"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true }}}}
__WD_Post: StatusCode=200; ResponseText={"value":{"capabilities":{"acceptInsecureCerts":false,"browserName":"chrome","browserVersion":"86.0.4240.111","chrome":{"chromedriverVersion":"85.0.4183.87 (cd6713ebf92fa1cacc0f1a598df280093af0c5d7-refs/branch-heads/4183@{#1689})","userDataDir":"C:\\Users\\rixa\\AppData\\Local\\Temp\\2\\scoped_dir7256_163206879"},"goog:chromeOptions":{"debuggerAddress":"localhost:62650"},"networkConnectionEnabled":false,"pageLoadStrategy":"normal","platformName":"windows","proxy":{},"setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify","webauthn:virtualAuthenticators":true},"sessionId":"7d01eafc2a61d93cd27f0adeea3128b9"}}
_WD_CreateSession: {"value":{"capabilities":{"acceptInsecureCerts":false,"browserName":"chrome","browserVersion":"86.0.4240.111","chrome":{"chromedriverVersion":"85.0.4183.87 (cd6713ebf92fa1cacc0f1a598df280093af0c5d7-refs/branch-heads/4183@{#1689})","userDataDir":"C:\\Users\\rixa\\AppData\\Local\\Temp\\2\\scoped_dir7256_163206879"},"goog:chromeOptions":{"debuggerAddress":"localhost:62650"},"networkConnectionEnabled":false,"pageLoadStrategy":"normal","platformName":"windows","proxy":{},"setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify","webauthn:virtualAuthenticators":true},"sessionId":"7d01eafc2a61d93cd27f0adeea3128b9"}}
Bypass: SmokeTests
+Running: SmokeTest_SearchAMatter
__WD_Post: URL=HTTP://127.0.0.1:9515/session/7d01eafc2a61d93cd27f0adeea3128b9/url; $sData={"url":"http://wslive01az.bwlaw.co.uk:8080/WorkspaceWeb/"}
__WD_Post: StatusCode=200; ResponseText={"value":null}
_WD_Navigate: {"value":null}
__WD_Post: URL=HTTP://127.0.0.1:9515/session/7d01eafc2a61d93cd27f0adeea3128b9/element; $sData={"using":"xpath","value":"/html/body/div[1]/div[3]/div[1]/div[1]/div[1]/div/div/div[1]/div/div/input[1]"}
__WD_Post: StatusCode=404; ResponseText={"value":{"error":"no such element","message":"no such element: Unable to locate element: {\"method\":\"xpath\",\"selector\":\"/html/body/div[1]/div[3]/div[1]/div[1]/div[1]/div/div/div[1]/div/div/input[1]\"}\n  (Session info: chrome=86.0.4240.111)","stacktrace":"Backtrace:\n\tOrdinal0 [0x003FD383+3134339]\n\tOrdinal0 [0x002EA171+2007409]\n\tOrdinal0 [0x0018AEE8+569064]\n\tOrdinal0 [0x0011A72F+108335]\n\tOrdinal0 [0x00139DB0+236976]\n\tOrdinal0 [0x0012EC90+191632]\n\tOrdinal0 [0x00138773+231283]\n\tOrdinal0 [0x0012EB0B+191243]\n\tOrdinal0 [0x00112E77+77431]\n\tOrdinal0 [0x00113E3E+81470]\n\tOrdinal0 [0x00113DC9+81353]\n\tOrdinal0 [0x00300CD9+2100441]\n\tGetHandleVerifier [0x0056B75A+1396954]\n\tGetHandleVerifier [0x0056B3D9+1396057]\n\tGetHandleVerifier [0x00577126+1444518]\n\tGetHandleVerifier [0x0056BCE8+1398376]\n\tOrdinal0 [0x002F7F51+2064209]\n\tOrdinal0 [0x003022EB+2106091]\n\tOrdinal0 [0x00302411+2106385]\n\tOrdinal0 [0x003149C4+2181572]\n\tBaseThreadInitThunk [0x76816359+25]\n\tRtlGetAppContainerNamedObjectPath [0x77807C24+228]\n\tRtlGetAppContainerNamedObjectPath [0x77807BF4+180]\n"}}
_WD_FindElement: {"value":{"error":"no such element","message":"no such element: Unable to locate element: {\"method\":\"xpath\",\"selector\":\"/html/body/div[1]/div[3]/div[1]/div[1]/div[1]/div/div/div[1]/div/div/input[1]\"}\n  (Session info: chrome=86.0.4240.111)","stacktrace":"Backtrace:\n\tOrdinal0 [0x003FD383+3134339]\n\tOrdinal0 [0x002EA171+2007409]\n\tOrdinal0 [0x0018AEE8+569064]\n\tOrdinal0 [0x0011A72F+108335]\n\tOrdinal0 [0x00139DB0+236976]\n\tOrdinal0 [0x0012EC90+191632]\n\tOrdinal0 [0x00138773+231283]\n\tOrdinal0 [0x0012EB0B+191243]\n\tOrdinal0 [0x00112E77+77431]\n\tOrdinal0 [0x00113E3E+81470]\n\tOrdinal0 [0x00113DC9+81353]\n\tOrdinal0 [0x00300CD9+2100441]\n\tGetHandleVerifier [0x0056B75A+1396954]\n\tGetHandleVerifier [0x0056B3D9+1396057]\n\tGetHandleVerifier [0x00577126+1444518]\n\tGetHandleVerifier [0x0056BCE8+1398376]\n\tOrdinal0 [0x002F7F51+2064209]\n\tOrdinal0 [0x003022EB+2106091]\n\tOrdinal0 [0x00302411+2106385]\n\tOrdinal0 [0x003149C4+2181572]\n\tBaseThreadInitThunk [0x76816359+25]\n\tRtlGetAppContainerNamedObjectPath [0x77807C24+228]\n\tRtlGetAppContainerNamedObjectPath [0x77807BF4+180]\n"}}
_WD_FindElement ==> No match: HTTP status = 404
__WD_Post: URL=HTTP://127.0.0.1:9515/session/7d01eafc2a61d93cd27f0adeea3128b9/element//value; $sData={"id":"", "text":"553625"}
__WD_Post: StatusCode=404; ResponseText={"value":{"error":"no such element","message":"no such element: Element_id length is invalid\n  (Session info: chrome=86.0.4240.111)","stacktrace":"Backtrace:\n\tOrdinal0 [0x003FD383+3134339]\n\tOrdinal0 [0x002EA171+2007409]\n\tOrdinal0 [0x0018AEE8+569064]\n\tOrdinal0 [0x0011A0C4+106692]\n\tOrdinal0 [0x00116200+90624]\n\tOrdinal0 [0x0012EC5D+191581]\n\tOrdinal0 [0x00114986+84358]\n\tOrdinal0 [0x0012ED31+191793]\n\tOrdinal0 [0x00138773+231283]\n\tOrdinal0 [0x0012EB0B+191243]\n\tOrdinal0 [0x00112E77+77431]\n\tOrdinal0 [0x00113E3E+81470]\n\tOrdinal0 [0x00113DC9+81353]\n\tOrdinal0 [0x00300CD9+2100441]\n\tGetHandleVerifier [0x0056B75A+1396954]\n\tGetHandleVerifier [0x0056B3D9+1396057]\n\tGetHandleVerifier [0x00577126+1444518]\n\tGetHandleVerifier [0x0056BCE8+1398376]\n\tOrdinal0 [0x002F7F51+2064209]\n\tOrdinal0 [0x003022EB+2106091]\n\tOrdinal0 [0x00302411+2106385]\n\tOrdinal0 [0x003149C4+2181572]\n\tBaseThreadInitThunk [0x76816359+25]\n\tRtlGetAppContainerNamedObjectPath [0x77807C24+228]\n\tRtlGetAppContainerNamedObjectPath [0x77807BF4+180]\n"}}
_WD_ElementAction: {"value":{"error":"no such element","message":"no such element: Element_id length is invalid\n  (Ses...
_WD_ElementAction ==> Webdriver Exception: {"value":{"error":"no such element","message":"no such element: Element_id length is invalid\n  (Session info: chrome=86.0.4240.111)","stacktrace":"Backtrace:\n\tOrdinal0 [0x003FD383+3134339]\n\tOrdinal0 [0x002EA171+2007409]\n\tOrdinal0 [0x0018AEE8+569064]\n\tOrdinal0 [0x0011A0C4+106692]\n\tOrdinal0 [0x00116200+90624]\n\tOrdinal0 [0x0012EC5D+191581]\n\tOrdinal0 [0x00114986+84358]\n\tOrdinal0 [0x0012ED31+191793]\n\tOrdinal0 [0x00138773+231283]\n\tOrdinal0 [0x0012EB0B+191243]\n\tOrdinal0 [0x00112E77+77431]\n\tOrdinal0 [0x00113E3E+81470]\n\tOrdinal0 [0x00113DC9+81353]\n\tOrdinal0 [0x00300CD9+2100441]\n\tGetHandleVerifier [0x0056B75A+1396954]\n\tGetHandleVerifier [0x0056B3D9+1396057]\n\tGetHandleVerifier [0x00577126+1444518]\n\tGetHandleVerifier [0x0056BCE8+1398376]\n\tOrdinal0 [0x002F7F51+2064209]\n\tOrdinal0 [0x003022EB+2106091]\n\tOrdinal0 [0x00302411+2106385]\n\tOrdinal0 [0x003149C4+2181572]\n\tBaseThreadInitThunk [0x76816359+25]\n\tRtlGetAppContainerNamedObjectPath [0x77807C24+228]\n\tRtlGetAppContainerNamedObjectPath [0x77807BF4+180]\n"}}
+Finished: SmokeTest_SearchAMatter

 

 

Edited by CaptainBeardsEyesBeard
Link to post
Share on other sites

Hello, 

You could try

_WD_WaitElement ($sSession, $_WD_LOCATOR_ByXPath, "//Input[@class='form-control ezpz-hint']","",5000)
$aElements = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//Input[@class='form-control ezpz-hint']")
_WD_ElementAction($sSession, $aElements, 'value', "553625")

or 

_WD_WaitElement ($sSession, $_WD_LOCATOR_ByXPath, "//Input[@name='ezpz_hint_dummy_input']","",5000)
$aElements = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//Input[@name='ezpz_hint_dummy_input']")
_WD_ElementAction($sSession, $aElements, 'value', "553625")

 

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

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.

×
×
  • Create New...