Danp2 Posted May 16, 2018 Author Share Posted May 16, 2018 1 hour ago, Decibel said: Right. I put the failed attempts in as comments to be comprehensive for others to see what I tried. OIC... that wasn't clear to me at first. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Danp2 Posted May 16, 2018 Author Share Posted May 16, 2018 @horphi Can you show us a working example? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
horphi Posted May 18, 2018 Share Posted May 18, 2018 It´s really simple. The interaction with the frame will be automatically initiated by the web driver. You only need to pass the right ID of the Frame. On my page i have only 1 Frame and that means = 0. _WD_Window($sSession, 'frame', '{"id":0}') $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '//p') _WD_ElementAction($sSession, $sElement, 'click') What i try as next step is to select the text inside the Frame, but still no success... ;-) BR Link to comment Share on other sites More sharing options...
Danp2 Posted May 18, 2018 Author Share Posted May 18, 2018 I was reading the W3C specs the other day and it appears that you can also pass an element reference id. I will have to do some manual testing with this to confirm that it works as expected and that the value being returned by _WD_FindElement is correct. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
horphi Posted May 20, 2018 Share Posted May 20, 2018 (edited) I don´t know, why the WD does not return the string that i placed 1. i switch into the iframe 2.i execute the JS Script to receive the Text... value is anytime NULL Func _pasteIntoText() ;im Editor Texte markieren $sSearchtext = GUICtrlRead($Input1);--> document.getElementsByTagName('p')[0].innerHTML; $sStrategy = GUICtrlRead($Input2) ;--> empty _WD_Window($sSession, 'frame', '{"id":0}') $sElemtent = _WD_ExecuteScript($sSession, $sSearchtext, $sStrategy) _WD_Window($sSession, 'parent', '{"id":0}') EndFunc ;==>_pasteIntoText <iframe allowfullscreen="true" src="javascript:false" style="width: 508px; height: 311px;" tabindex="3" frameborder="0"> <html> <head> <style>.ie * {min-height: auto !important} .ie table td {height:15px}</style> <meta http-equiv="Content-Type" content="text/html;charset=utf-8"> </head> <body dir="ltr" contenteditable="true"> <p align="center">test</p> </body> </html> </iframe> __WD_Post: URL=HTTP://127.0.0.1:4444/session/b0688555-6204-4ff2-a10f-75b44adda672/execute/sync; $sData={"script":"document.getElementsByTagName('p')[0].innerHTML;", "args":[]} __WD_Post: StatusCode=200; ResponseText={"value":null} _WD_ExecuteScript: {"value":null} BR horphi Edited May 20, 2018 by horphi Link to comment Share on other sites More sharing options...
Danp2 Posted May 20, 2018 Author Share Posted May 20, 2018 (edited) You aren't returning a value from your script. Therefore, the result is null. Edited May 20, 2018 by Danp2 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
horphi Posted May 21, 2018 Share Posted May 21, 2018 (edited) 20 hours ago, Danp2 said: You aren't returning a value from your script. Therefore, the result is null. Your´re right...forgot to state "return" return document.getElementsByTagName('p')[3].innerHTML; __WD_Post: URL=HTTP://127.0.0.1:4444/session/b15514ad-6d2e-4c76-94b4-b35a542620b6/execute/sync; $sData={"script":"return document.getElementsByTagName('p')[3].innerHTML; ", "args":[]} __WD_Post: StatusCode=200; ResponseText={"value":"[attach]"} Did you tested to get a array back instead of a string? If i look for a specific value, then i need to execute the script several times, until i find the right one.. Or lets say, @ the END i will "select" the given value. Normally: return document.getElementsByTagName('p')[3].select; --> but nothing happens... :-( BR Edited May 21, 2018 by horphi Link to comment Share on other sites More sharing options...
Danp2 Posted May 21, 2018 Author Share Posted May 21, 2018 43 minutes ago, horphi said: Did you tested to get a array back instead of a string? If i look for a specific value, then i need to execute the script several times, until i find the right one. No, I haven't. Can you provide an example that shows what you are attempting to do? P.S. If you are trying to return an array of elements, then you should look at _WD_FindElement Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
BobMerit Posted May 23, 2018 Share Posted May 23, 2018 Have I found an error in the code? I am under the impression that WD_FindElement will return an array so I am assuming that part might work at least it was stated by the code author. But using $_WD_LOCATOR_ByClassName seems incomplete. WD_Post doesn't seem to have a clue how to process the request. My project is 90% complete and I can't get past this point. I have to find some way to generate a list of elements and somehow sequence through them. Thanks for any help. $checkboxarray = _WD_FindElement($sSession, $_WD_LOCATOR_ByClassName, "x-tree-checkbox") _ArrayDisplay($checkboxarray) __WD_Post: URL=HTTP://127.0.0.1:4444/session/56d9c46d-6959-473b-980c-22830313d944/element; $sData={"using":"class name","value":"x-tree-checkbox"} __WD_Post: StatusCode=400; ResponseText={"value":{"error":"invalid argument","message":"Unknown locator strategy class name","stacktrace":""}} _WD_FindElement: {"value":{"error":"invalid argument","message":"Unknown locator strategy class name","stacktrace":""}} _WD_FindElement ==> Webdriver Exception: HTTP status = 400 Link to comment Share on other sites More sharing options...
Danp2 Posted May 24, 2018 Author Share Posted May 24, 2018 Not an error in the code, per se. Looking at the latest W3C specs, these are the only supported locator strategies -- Quote State Keyword CSS selector "css selector" Link text selector "link text" Partial link text selector "partial link text" Tag name "tag name" XPath selector "xpath" So, passing one of the other locator constants will result in the error you received. I'll need to do some research to determine if these need to be removed or if they are valid in other instances. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Danp2 Posted May 24, 2018 Author Share Posted May 24, 2018 3 hours ago, BobMerit said: I am under the impression that WD_FindElement will return an array so I am assuming that part might work at least it was stated by the code author. Actually, it will return an array, but only if $lMultiple is True. If not, then it returns a single element id. Here's one way that you could try rewriting your code to use xpath -- $checkboxarray = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, ".x-tree-checkbox", "", True) _ArrayDisplay($checkboxarray) SkysLastChance and horphi 2 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
BobMerit Posted May 24, 2018 Share Posted May 24, 2018 I certainly appreciate your response. It did change the error message. I seem to be pushing the limit of what can be done. $checkboxarray = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, ".x-tree-checkbox", "", True) _ArrayDisplay($checkboxarray) __WD_Post: URL=HTTP://127.0.0.1:4444/session/171a5d58-3d1e-4fc7-8843-5363915d5e72/elements; $sData={"using":"xpath","value":".x-tree-checkbox"} __WD_Post: StatusCode=400; ResponseText={"value":{"error":"invalid selector","message":"Given xpath expression \".x-tree-checkbox\" is invalid: SyntaxError: The expression is not a legal expression.","stacktrace":"WebDriverError@chrome://marionette/content/error.js:178:5\nInvalidSelectorError@chrome://marionette/content/error.js:336:5\nfind_@chrome://marionette/content/element.js:376:11\nelement.find/</findElements<@chrome://marionette/content/element.js:317:17\nevalFn@chrome://marionette/content/sync.js:86:7\nPollPromise/<@chrome://marionette/content/sync.js:101:5\nPollPromise@chrome://marionette/content/sync.js:81:10\nelement.find/<@chrome://marionette/content/element.js:316:24\nelement.find@chrome://marionette/content/element.js:315:10\nfindElementsContent@chrome://marionette/content/listener.js:1170:19\ndispatch/</req<@chrome://marionette/content/listener.js:489:14\ndispatch/<@chrome://marionette/content/listener.js:484:15\n"}} _WD_FindElement: {"value":{"error":"invalid selector","message":"Given xpath expression \".x-tree-checkbox\" is invalid: SyntaxError: The expression is not a legal expression.","stacktrace":"WebDriverError@chrome://marionette/content/error.js:178:5\nInvalidSelectorError@chrome://marionette/content/error.js:336:5\nfind_@chrome://marionette/content/element.js:376:11\nelement.find/</findElements<@chrome://marionette/content/element.js:317:17\nevalFn@chrome://marionette/content/sync.js:86:7\nPollPromise/<@chrome://marionette/content/sync.js:101:5\nPollPromise@chrome://marionette/content/sync.js:81:10\nelement.find/<@chrome://marionette/content/element.js:316:24\nelement.find@chrome://marionette/content/element.js:315:10\nfindElementsContent@chrome://marionette/content/listener.js:1170:19\ndispatch/</req<@chrome://marionette/content/listener.js:489:14\ndispatch/<@chrome://marionette/content/listener.js:484:15\n"}} _WD_FindElement ==> Webdriver Exception: HTTP status = 400 Link to comment Share on other sites More sharing options...
Danp2 Posted May 24, 2018 Author Share Posted May 24, 2018 15 minutes ago, BobMerit said: I seem to be pushing the limit of what can be done Not really... just have to get the syntax right. I likely steered you in the wrong direction because that's actually a CSS selector. Try changing $_WD_LOCATOR_ByXPath to $_WD_LOCATOR_ByCSSSelector. If that doesn't work, then you should probably share more details about the element(s) you are attempting to locate (show us the associated HTML). Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
BobMerit Posted May 24, 2018 Share Posted May 24, 2018 Oooooo oooo oooo i got a bite. This might work. $checkboxarray = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, ".x-tree-checkbox", "", True) _ArrayDisplay($checkboxarray) Link to comment Share on other sites More sharing options...
BobMerit Posted May 24, 2018 Share Posted May 24, 2018 Thank you!! I was able to pick the array id from the $checkboxarray[1] and use that to check the box. I didn't think that was going to work at all. lol Huh Very interesting. Link to comment Share on other sites More sharing options...
grzesiek Posted May 24, 2018 Share Posted May 24, 2018 I tried the example code with chrome and received error when testing timeouts 'SetTimeout unknown error: 'ms' must be a double'. Link to comment Share on other sites More sharing options...
Danp2 Posted May 24, 2018 Author Share Posted May 24, 2018 (edited) @grzesiek Thanks for the report. I'll look into it when I have a moment. Edit: This appears to be an issue with the ChromeDriver implemenation. See here for more details. Edited May 24, 2018 by Danp2 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
horphi Posted May 24, 2018 Share Posted May 24, 2018 Hi, i´m irritated this works _WD_ExecuteScript($sSession, 'return document.getElementsByTagName('p')[1].innerHTML;') __WD_Post: URL=HTTP://127.0.0.1:4444/session/fc4b43b3-2c7b-4ce1-92fb-660e2d017aab/execute/sync; $sData={"script":"return document.getElementsByTagName('p')[1].innerHTML; ", "args":[[]]} __WD_Post: StatusCode=200; ResponseText={"value":"test2"} _WD_ExecuteScript: {"value":"test2"} But this not LINK _WD_ExecuteScript($sSession, 'document.getElementsByTagName('p')[1].select;') __WD_Post: URL=HTTP://127.0.0.1:4444/session/fc4b43b3-2c7b-4ce1-92fb-660e2d017aab/execute/sync; $sData={"script":" document.getElementsByTagName('p')[1].select; ", "args":[[]]} __WD_Post: StatusCode=200; ResponseText={"value":null} _WD_ExecuteScript: {"value":null} Can someone explain to me what i don´t understand again??? Many thanks horphi Link to comment Share on other sites More sharing options...
Danp2 Posted May 24, 2018 Author Share Posted May 24, 2018 @horphi It's not clear what you are trying to accomplish. Please state your goal so that we can better assist you. P.S. Please post your general support questions in this thread -- horphi 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
grzesiek Posted May 24, 2018 Share Posted May 24, 2018 @horphi Try this: _WD_ExecuteScript($sSession, 'document.getElementsByTagName('p')[1].select();') 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