Danp2 Posted July 18, 2018 Author Share Posted July 18, 2018 @nulee See my reply in the other thread Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
haijie1223 Posted July 20, 2018 Share Posted July 20, 2018 @Danyfirex how to HighlightElement in browser?why my browser is not effective? Link to comment Share on other sites More sharing options...
Danp2 Posted July 20, 2018 Author Share Posted July 20, 2018 @haijie1223 We aren't mind readers. Show us your code. Post the results from the Scite output window. Also tell us which browser and web driver (including version for both) . Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
haijie1223 Posted July 20, 2018 Share Posted July 20, 2018 @Danp2 WDVERSION = "0.1.0.10" and the code : expandcollapse popup#include <wd_core.au3> Local $sDesiredCapabilities='{}' _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, "http://www.google.com") Local $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//*[@id='hplogo']") __WD_HighlightElement($sSession, $sElement) $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//*[@name='btnK']") __WD_HighlightElement($sSession, $sElement,2) Local $aElements = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//*[@class='gb_P']", "", True) __WD_HighlightElements($sSession, $aElements,3) Sleep(10000) _WD_DeleteSession($sSession) _WD_Shutdown() ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name ..........: __WD_HighlightElement ; Description ...: ; Syntax ........: __WD_HighlightElement($sSession, $sElement[, $iMethod = 1]) ; Parameters ....: $sSession - Session ID from _WDCreateSession ; $sElement - Element ID from _WDFindElement ; $iMethod - [optional] an integer value. Default is 1. ; 1=style -> Highlight border dotted red ; 2=style -> Highlight yellow rounded box ; 3=style -> Highlight yellow rounded box + border dotted red ; Return values .: Success - True ; Failure - False ; Author ........: Your Name ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func __WD_HighlightElement($sSession, $sElement, $iMethod = 1) Local Const $aMethod[] = ["border: 2px dotted red", _ "background: #FFFF66; border-radius: 5px; padding-left: 3px;", _ "border:2px dotted red;background: #FFFF66; border-radius: 5px; padding-left: 3px;"] If $iMethod < 1 Or $iMethod > 3 Then $iMethod = 1 Local $sJsonElement = '{"element-6066-11e4-a52e-4f735466cecf":"' & $sElement & '"}' Local $sResponse = _WD_ExecuteScript($sSession, "arguments[0].style='" & $aMethod[$iMethod - 1] & "'; return true;", $sJsonElement) Local $sJSON = Json_Decode($sResponse) Local $sResult = Json_Get($sJSON, "[value]") Return ($sResult = "true" ? SetError(0, 0, $sResult) : SetError(1, 0, False)) EndFunc ;==>__WD_HighlightElement ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name ..........: __WD_HighlightElements ; Description ...: ; Syntax ........: __WD_HighlightElements($sSession, $aElements[, $iMethod = 1]) ; Parameters ....: $sSession - Session ID from _WDCreateSession ; $aElements - an array of Elements ID from _WDFindElement ; $iMethod - [optional] an integer value. Default is 1. ; 1=style -> Highlight border dotted red ; 2=style -> Highlight yellow rounded box ; 3=style -> Highlight yellow rounded box + border dotted red ; Return values .: Success - True ; Failure - False ; @Extended Number of Highlighted Elements ; Author ........: Your Name ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func __WD_HighlightElements($sSession, $aElements, $iMethod = 1) Local $iHighlightedElements = 0 For $i = 0 To UBound($aElements) - 1 $iHighlightedElements += (__WD_HighlightElement($sSession, $aElements[$i], $iMethod) = True ? 1 : 0) Next Return ($iHighlightedElements > 0 ? SetError(0, $iHighlightedElements, True) : SetError(1, 0, False)) EndFunc ;==>__WD_HighlightElements the browser is chrome 67.0.3396.99 the scite console code : _WD_Startup ==> Invalid value: Location for Web Driver not set. __WD_Post: URL=HTTP://127.0.0.1:0/session; $sData={} __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:0/session//url; $sData={"url":"http://www.google.com"} __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:0/session//element; $sData={"using":"xpath","value":"//*[@id='hplogo']"} __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:0/session//execute/sync; $sData={"script":"arguments[0].style='border: 2px dotted red'; return true;", "args":[{"element-6066-11e4-a52e-4f735466cecf":""}]} __WD_Post: StatusCode=0; ResponseText=0 __WD_Post ==> Send / Recv error _WD_ExecuteScript: 0 __WD_Post: URL=HTTP://127.0.0.1:0/session//element; $sData={"using":"xpath","value":"//*[@name='btnK']"} __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:0/session//execute/sync; $sData={"script":"arguments[0].style='background: #FFFF66; border-radius: 5px; padding-left: 3px;'; return true;", "args":[{"element-6066-11e4-a52e-4f735466cecf":""}]} __WD_Post: StatusCode=0; ResponseText=0 __WD_Post ==> Send / Recv error _WD_ExecuteScript: 0 __WD_Post: URL=HTTP://127.0.0.1:0/session//elements; $sData={"using":"xpath","value":"//*[@class='gb_P']"} __WD_Post: StatusCode=0; ResponseText=0 __WD_Post ==> Send / Recv error _WD_FindElement: 0 _WD_FindElement ==> Send / Recv error: HTTP status = 0 __WD_Delete: URL=HTTP://127.0.0.1:0/session/ __WD_Delete: StatusCode=0; ResponseText=0 __WD_Delete ==> Webdriver Exception _WD_DeleteSession: 0 _WD_DeleteSession ==> Webdriver Exception: HTTP status = 0 Link to comment Share on other sites More sharing options...
haijie1223 Posted July 20, 2018 Share Posted July 20, 2018 @Danp2 The reason found, my geckodriver.exe path is error Link to comment Share on other sites More sharing options...
Danp2 Posted July 20, 2018 Author Share Posted July 20, 2018 @haijie1223 Right. Also, there's a newer version of the UDF that includes _WD_HighlightElement (note the name change). Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
BigDaddyO Posted July 23, 2018 Share Posted July 23, 2018 Mouseover using chromedriver? I need to close some tabs inside a webpage but the x that you click on is not visible until you mouseover the tab you want to close. Anybody know how I would be able to kick off a mouseover? I tried just doing a _WD_ElementAction($sSession, $eClose, "click") while the button was still hidden but it says: _WD_ElementAction: {"value":{"error":"element not visible","message":"(Session infochrome=67.0.3396.99)" I put together a sample script where if we get the Mouseover working it should set the text with a yellow background. #include "wd_core.au3" #include "wd_helper.au3" Local $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"chromeOptions": {"w3c": true, "args":["start-maximized", "disable-infobars"] }}}}' Local $sSession $_WD_DEBUG = True ;This outputs a TON of debugging stuff to the Console, set to False before compiling. $sSetup = _SetupChrome() ;Setup all the requirements for WebDriver to use Chrome how we want $iStartup = _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) ;Launch Chrome Now $sNavigate = _WD_Navigate($sSession, "https://www.w3schools.com/jquery/tryit.asp?filename=tryjquery_event_mouseover_mouseout") ;Go to the test site sleep(1500) $sFrame = _WD_FrameEnter($sSession, "iframeResult") ;I have to use the $sOption = '{"id":"' & $sIndexOrID & '"}' change to get this function to work properly $eHoverItem = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//p[text()='Move the mouse pointer over this paragraph.']") ;Find the p element we want to mouseover _WD_HighlightElement($sSession, $eHoverItem, 1) ;Put the dotted line around just to show we have found it ;How to do a Hover/Mouseover? Func _SetupChrome() If _WD_Option('Driver', 'chromedriver.exe') = 0 Then Return SetError(1) If _WD_Option('Port', 9515) = 0 Then Return SetError(1) If _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"') = 0 Then Return SetError(1) EndFunc ;==>_SetupChrome Thanks for any help Mike Link to comment Share on other sites More sharing options...
Danp2 Posted July 23, 2018 Author Share Posted July 23, 2018 Have a look at _WD_Action and the "actions" command. This is where I suspect that the web driver would implement this kind of thing. Also see here for the details in the W3C specs. P.S. Let me know how it goes with this. Once you have it working, I can add an example to wd_test. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
BigDaddyO Posted July 24, 2018 Share Posted July 24, 2018 17 hours ago, Danp2 said: Have a look at _WD_Action and the "actions" command. This is where I suspect that the web driver would implement this kind of thing. Also see here for the details in the W3C specs. P.S. Let me know how it goes with this. Once you have it working, I can add an example to wd_test. That W3C spec makes no sense to me and everything from google searches just bring up Selenium stuff which doesn't work here. on the bright side, I did discover that doing _WD_ElementAction($sSession, $eHoverItem, "click") actually performs a mouseover. I'm sure it's not the best option but in my case the click is ignored by the Tab item but the mouseover pops up the x for me to then click on. Link to comment Share on other sites More sharing options...
BigDaddyO Posted July 24, 2018 Share Posted July 24, 2018 Hello again, I'm wondering why the _WD_FrameEnter can't seem to handle the value returned from _WD_FindElement()? I need to go into a frame but the @id changes every time I go into the page so I need to use xpath to find the proper frame, but I can't pass the value returned from _WD_FindElement(). Is there a way to get the @id from what _WD_FindElement() returns? Link to comment Share on other sites More sharing options...
Danp2 Posted July 24, 2018 Author Share Posted July 24, 2018 @BigDaddyO I'll see if I can come up with a working example of _WD_Action / hover. As far as your other question, have you tried testing with a different browser? We've already established that Chromedriver doesn't adhere to the W3C specs in a number of areas. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
PoojaKrishna Posted July 24, 2018 Share Posted July 24, 2018 (edited) On 7/17/2018 at 5:52 PM, Danp2 said: Probably could retrieve the values using _WD_ExecuteScript / Javascript. @Danp2, I'm trying to get the size and location using _WD_ExecuteScript and I could get the size of the element but not sure which property to use to get back the location, left and top. Please help if you have any idea regarding this. Have seen a sample of calling _WD_ExecuteScript on @Danyfirex 's _WD_HighlightElement and reused to call the method Local $sJsonElement = '{"' & $_WD_ELEMENT_ID & '":"' & $sElementId & '"}' Local $sResponse = _WD_ExecuteScript($sSession, "return arguments[0].clientHeight", $sJsonElement) msgbox(0,"Height",$sResponse) $sResponse = _WD_ExecuteScript($sSession, "return arguments[0].clientWidth", $sJsonElement) msgbox(0,"Width",$sResponse) #cs $sResponse = _WD_ExecuteScript($sSession, "return arguments[0].offsetLeft", $sJsonElement) msgbox(0,"Left",$sResponse) $sResponse = _WD_ExecuteScript($sSession, "return arguments[0].offsetTop", $sJsonElement) msgbox(0,"Top",$sResponse) #ce Thank you for all your help. Reference DOM Edited July 24, 2018 by PoojaKrishna Link to comment Share on other sites More sharing options...
BigDaddyO Posted July 24, 2018 Share Posted July 24, 2018 33 minutes ago, Danp2 said: @BigDaddyO I'll see if I can come up with a working example of _WD_Action / hover. As far as your other question, have you tried testing with a different browser? We've already established that Chromedriver doesn't adhere to the W3C specs in a number of areas. Thanks for looking into that. As for Firefox, My company doesn't allow it as they can't secure it how they want. I did finally figure out how to get the IFrame id using _WE_ElementAction() $eFrame = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//iframe[@name='iframeResult']") ;Find the IFrame we need ConsoleWrite(@CRLF & "Finding Frame result (" & $eFrame & ")" & @CRLF & @CRLF) $ID = _WD_ElementAction($sSession, $eFrame, 'attribute', 'id') ;Get the @id to pass into the _WD_FrameEnter ConsoleWrite(@CRLF & "Finding The Frame id result (" & $ID & ")" & @CRLF & @CRLF) $sFrame = _WD_FrameEnter($sSession, $ID) ConsoleWrite(@CRLF & "Enter Frame result (" & $sFrame & ")" & @CRLF & @CRLF) PoojaKrishna 1 Link to comment Share on other sites More sharing options...
Danp2 Posted July 24, 2018 Author Share Posted July 24, 2018 @PoojaKrishna There are lots of examples on the web for doing this. Here's one such example, which you should be able to translate into a series of _WD_ExecuteScript calls. PoojaKrishna 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Danyfirex Posted July 25, 2018 Share Posted July 25, 2018 Hello @BigDaddyO You can trigger the mouseover event using javascript. Local $sJsonElement = '{"element-6066-11e4-a52e-4f735466cecf":"' & $eHoverItem & '"}' Local $sResponse = _WD_ExecuteScript($sSession, "$('p').mouseover(); return true;", $sJsonElement) Saludos Saludos BigDaddyO 1 Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
PoojaKrishna Posted July 25, 2018 Share Posted July 25, 2018 11 hours ago, Danp2 said: @PoojaKrishna There are lots of examples on the web for doing this. Here's one such example, which you should be able to translate into a series of _WD_ExecuteScript calls. Thank you so much @Danp2, it worked!!! Reference Local $sJsonElement = '{"' & $_WD_ELEMENT_ID & '":"' & $sElementId & '"}' _WD_ExecuteScript($sSession, "return arguments[0].getBoundingClientRect().left", $sJsonElement) _WD_ExecuteScript($sSession, "return arguments[0].getBoundingClientRect().top", $sJsonElement) _WD_ExecuteScript($sSession, "return arguments[0].getBoundingClientRect().right", $sJsonElement) _WD_ExecuteScript($sSession, "return arguments[0].getBoundingClientRect().bottom", $sJsonElement) _WD_ExecuteScript($sSession, "return arguments[0].getBoundingClientRect().x", $sJsonElement) _WD_ExecuteScript($sSession, "return arguments[0].getBoundingClientRect().y", $sJsonElement) _WD_ExecuteScript($sSession, "return arguments[0].getBoundingClientRect().width", $sJsonElement) _WD_ExecuteScript($sSession, "return arguments[0].getBoundingClientRect().height", $sJsonElement) BigDaddyO 1 Link to comment Share on other sites More sharing options...
PoojaKrishna Posted July 25, 2018 Share Posted July 25, 2018 Back again with a question. I am trying to context click on an element. Can I use _WD_Action to context click an element ? I know _WD_ExecuteScript can be used but can we create object of class action to use in the script and pass as parameter? If any one has a sample script, then please post. It would be a great help. _WD_Action($sSession, 'actions', 'contextClick') Link to comment Share on other sites More sharing options...
Danp2 Posted July 25, 2018 Author Share Posted July 25, 2018 @PoojaKrishna Here's an example I was able to come up with after some Googling -- _WD_Navigate($sSession, "http://google.com") $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@id='lst-ib']") $sAction = '{"actions":[{"id":"default mouse","type":"pointer","parameters":{"pointerType":"mouse"},"actions":[{"duration":100,"x":0,"y":0,"type":"pointerMove","origin":{"ELEMENT":"' $sAction &= $sElement & '","' & $_WD_ELEMENT_ID & '":"' & $sElement & '"}},{"button":2,"type":"pointerDown"},{"button":2,"type":"pointerUp"}]}]}' _WD_Action($sSession, "actions", $sAction) Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Danp2 Posted July 25, 2018 Author Share Posted July 25, 2018 @BigDaddyO You may want to try the above while removing the pointerDown and pointerUp portion to see if it triggers the hover event you were needing. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
PoojaKrishna Posted July 26, 2018 Share Posted July 26, 2018 8 hours ago, Danp2 said: @PoojaKrishna Here's an example I was able to come up with after some Googling -- _WD_Navigate($sSession, "http://google.com") $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@id='lst-ib']") $sAction = '{"actions":[{"id":"default mouse","type":"pointer","parameters":{"pointerType":"mouse"},"actions":[{"duration":100,"x":0,"y":0,"type":"pointerMove","origin":{"ELEMENT":"' $sAction &= $sElement & '","' & $_WD_ELEMENT_ID & '":"' & $sElement & '"}},{"button":2,"type":"pointerDown"},{"button":2,"type":"pointerUp"}]}]}' _WD_Action($sSession, "actions", $sAction) Thank you @Danp2 but it returns an error on my testings. {"value":{"error":"unknown command","message":"(Session infochrome=67.0.3396.99)","stacktrace":"Backtrace:\n\tOrdinal0 [0x013DDF70+778096]\n\tOrdinal0 [0x0138B42D+439341]\n\tOrdinal0 [0x01367E1D+294429]\n\tOrdinal0 [0x0134D9D3+186835]\n\tOrdinal0 [0x01348323+164643]\n\tOrdinal0 [0x01331B45+72517]\n\tOrdinal0 [0x01332F2A+77610]\n\tOrdinal0 [0x01332ECC+77516]\n\tGetHandleVerifier [0x01479936+3478]\n\tOrdinal0 [0x013E88C3+821443]\n\tOrdinal0 [0x01397066+487526]\n\tOrdinal0 [0x01397393+488339]\n\tOrdinal0 [0x013974A3+488611]\n\tOrdinal0 [0x013EAA67+830055]\n\tOrdinal0 [0x01396DAF+486831]\n\tOrdinal0 [0x013A13FE+529406]\n\tOrdinal0 [0x013AC57B+574843]\n\tOrdinal0 [0x013AC6CD+575181]\n\tOrdinal0 [0x013AB92B+571691]\n\tBaseThreadInitThunk [0x76C88484+36]\n\tRtlValidSecurityDescriptor [0x774D2FEA+282]\n\tRtlValidSecurityDescriptor [0x774D2FBA+234]\n"}} The action statement was like: {"actions":[{"id":"default mouse","type":"pointer","parameters":{"pointerType":"mouse"},"actions":[{"duration":100,"x":0,"y":0,"type":"pointerMove","origin":{"ELEMENT":"978ac653-1ffa-46a1-bf0b-c3551ffd74a6","element-6066-11e4-a52e-4f735466cecf":"978ac653-1ffa-46a1-bf0b-c3551ffd74a6"}},{"button":2,"type":"pointerDown"},{"button":2,"type":"pointerUp"}]}]} Link to comment Share on other sites More sharing options...
Recommended Posts