Danp2 Posted May 3, 2021 Author Share Posted May 3, 2021 33 minutes ago, Schmand said: "//p[@class='buttonbar Anmeldung']" That class belongs to the button, not the paragraph element. What you want would be something like one of these -- "//p/button[@class='buttonbar Anmeldung']" "//button[@class='buttonbar Anmeldung']" "//button[@type='submit']" Another option would be to use the button's text as a selector. Lots of ways to skin a cat. 😅 Schmand 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Marlon13 Posted May 3, 2021 Share Posted May 3, 2021 (edited) 1 hour ago, Danp2 said: @Marlon13 You may want to check the file msedge.log to see if there's any explanation for why it starts returning empty strings at row 20. On you new issue... You're really going to make me ask you again for the details necessary to help you? 😦 log.txt Edited May 3, 2021 by Marlon13 Link to comment Share on other sites More sharing options...
Schmand Posted May 3, 2021 Share Posted May 3, 2021 18 minutes ago, Danp2 said: That class belongs to the button, not the paragraph element. What you want would be something like one of these -- "//p/button[@class='buttonbar Anmeldung']" "//button[@class='buttonbar Anmeldung']" "//button[@type='submit']" Another option would be to use the button's text as a selector. Lots of ways to skin a cat. 😅 Thank you for assistance. Now Iam struggling with some wiered method for "buttons". I can enter the user name without any problems. The ID remains permanently the same as "UserName". Unfortunately, however, the "ID", which was marked in red, changes after each refresh of the page. I have tried the whole thing using these codes: Local $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//button[@class='Button ButtonIcon SuggestiveBackground NormalState']") Unfortunately, this was not successful. _WD_ElementAction: {"value":{"error":"no such element","message":"no such element: Element_id length is invalid\n (Ses... _WD_ElementAction ==> No match: {"value":{"error":"no such element","message":"no such element: Element_id length is invalid\n (Session info: chrome=90.0.4430.93)","stacktrace":"Backtrace:\n\tOrdinal0 [0x0045C013+2474003]\n\tOrdinal0 [0x003F29C1+2042305]\n\tOrdinal0 [0x00302F68+1060712]\n\tOrdinal0 [0x0032D141+1233217]\n\tOrdinal0 [0x0032EDFE+1240574]\n\tOrdinal0 [0x003247B3+1198003]\n\tOrdinal0 [0x00346813+1337363]\n\tOrdinal0 [0x003246A6+1197734]\n\tOrdinal0 [0x003468FA+1337594]\n\tOrdinal0 [0x003555CB+1398219]\n\tOrdinal0 [0x003466DB+1337051]\n\tOrdinal0 [0x00323427+1192999]\n\tOrdinal0 [0x003242EE+1196782]\n\tOrdinal0 [0x00324279+1196665]\n\tGetHandleVerifier [0x005E96FC+1590332]\n\tGetHandleVerifier [0x00698614+2306900]\n\tGetHandleVerifier [0x004E9E93+543699]\n\tGetHandleVerifier [0x004E92CE+540686]\n\tOrdinal0 [0x003F86BA+2066106]\n\tOrdinal0 [0x003FD1C8+2085320]\n\tOrdinal0 [0x003FD308+2085640]\n\tOrdinal0 [0x004067F3+2123763]\n\tBaseThreadInitThunk [0x77BCFA29+25]\n\tRtlGetAppContainerNamedObjectPath [0x77D17A7E+286]\n\tRtlGetAppContainerNamedObjectPath [0x77D17A4E+238]\n"}} >Exit code: 0 Time: 5.526 Is there an alternative for this? The xPath would be "//*[@id="zfdffa0fc5987456aa232806b13da961a"]" Unfortunately, however, this does not remain the same as described. I have also not found a "button" in the source code. It is a riddle to me how the whole thing is called up. Thank you! Link to comment Share on other sites More sharing options...
Danp2 Posted May 3, 2021 Author Share Posted May 3, 2021 @Marlon13 This is something that you will need to debug yourself unless someone else wants to jump in and help. FWIW, I took a quick glance and didn't see any issues. I would ask if you are sure this came from the same run that produced the earlier screenshot? Reason being that there are values showing in the log that are in the 112.00 and beyond range that weren't in the array display. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Danp2 Posted May 3, 2021 Author Share Posted May 3, 2021 @Schmand That's a link element, not a button. Suggest that you try _WD_LinkClickByText. Schmand 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Schmand Posted May 3, 2021 Share Posted May 3, 2021 10 minutes ago, Danp2 said: @Schmand That's a link element, not a button. Suggest that you try _WD_LinkClickByText. Thank you again. Its working now Link to comment Share on other sites More sharing options...
Marlon13 Posted May 3, 2021 Share Posted May 3, 2021 12 minutes ago, Danp2 said: @Marlon13 This is something that you will need to debug yourself unless someone else wants to jump in and help. FWIW, I took a quick glance and didn't see any issues. I would ask if you are sure this came from the same run that produced the earlier screenshot? Reason being that there are values showing in the log that are in the 112.00 and beyond range that weren't in the array display. I run and add a attach sorry msedge.log Link to comment Share on other sites More sharing options...
HJL Posted May 3, 2021 Share Posted May 3, 2021 (edited) Hi Dan, how can we open a window with a specific size? So far we have used _WD_NewTab($sSession, True, -1, $sURL, ', width=1450, height=900'). Is there any way to do it with _WD_Window()? Edited May 3, 2021 by HJL Link to comment Share on other sites More sharing options...
Danp2 Posted May 3, 2021 Author Share Posted May 3, 2021 @HJL Looking at the W3C specs, the following should work (untested) -- $sTabHandle = _WD_Window($sSession, 'new', '{"type":"window"}') Not sure what size the window will be by default, but you will likely need to call _WD_Window to resize it to your desired size. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
HJL Posted May 3, 2021 Share Posted May 3, 2021 22 minutes ago, Danp2 said: @HJL Looking at the W3C specs, the following should work (untested) -- $sTabHandle = _WD_Window($sSession, 'new', '{"type":"window"}') Not sure what size the window will be by default, but you will likely need to call _WD_Window to resize it to your desired size. I don't find a working $sOption, tried different combinations: $sRes = _WD_Window($sSession, 'Rect', "{height:850, width:1000}") => Error = 5 $sRes = _WD_Window($sSession, 'Rect', "{, height:850, width:1000}") => Error = 5 $sRes = _WD_Window($sSession, 'Rect', "{ height=850, width=1000}") => Error = 5 Link to comment Share on other sites More sharing options...
Danp2 Posted May 3, 2021 Author Share Posted May 3, 2021 16 minutes ago, HJL said: I don't find a working $sOption, tried different combinations: You must not have tried very hard. 🤨 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
seadoggie01 Posted May 3, 2021 Share Posted May 3, 2021 (edited) @HJL It needs to be valid JSON... something like this: '{"height": 850, "width": 1000}' Nice WebDriver spec: https://github.com/jlipps/simple-wd-spec#set-window-rect Check your JSON: https://jsonformatter.org/json-pretty-print Edited May 3, 2021 by seadoggie01 Ninja'd All my code provided is Public Domain... but it may not work. Use it, change it, break it, whatever you want. Spoiler My Humble Contributions:Personal Function Documentation - A personal HelpFile for your functionsAcro.au3 UDF - Automating Acrobat ProToDo Finder - Find #ToDo: lines in your scriptsUI-SimpleWrappers UDF - Use UI Automation more Simply-erKeePass UDF - Automate KeePass, a password managerInputBoxes - Simple Input boxes for various variable types Link to comment Share on other sites More sharing options...
HJL Posted May 3, 2021 Share Posted May 3, 2021 One of my first tries actually was: $sResult = _WD_Window($sSession, 'Rect') => $sResult = "" (not something like {"x":3,"y":3,"width":1295,"height":1077}) What was wrong? $sResult = _WD_Window($sSession, 'Rect', '{"height":850, "width":1000}') works fine. WebDriver spec: https://github.com/jlipps/simple-wd-spec#set-window-rect : very good explanations! Thanks to both of you and have a nice evening! Link to comment Share on other sites More sharing options...
Danp2 Posted May 3, 2021 Author Share Posted May 3, 2021 @HJL I think the functionality changed a while back so that an object is returned instead of the raw JSON string. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
ThomasBennett Posted May 4, 2021 Share Posted May 4, 2021 Good morning everyone, ;Loading... _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//div[@id='popups-loading']//div[contains(text(),'Loading...')]") $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//div[@id='popups-loading']//div[contains(text(),'Loading...')]") If @error = $_WD_ERROR_NoMatch Then ;MsgBox($MB_SYSTEMMODAL, "Loading... message not found", "") ;MsgBox($MB_SYSTEMMODAL, "Click the Remove button", "//form[@id='s-library-template-unpublish-form']//input[@id='edit-submit']") _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//div[(@class='title') and text() = 'Remove Public Version']", Default, 30*60*1000) ;_WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//form[@id='s-library-template-unpublish-form']//input[@id='edit-submit']") $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//form[@id='s-library-template-unpublish-form']//input[@id='edit-submit']") _WD_ElementAction($sSession, $sElement, 'click') _WD_LoadWait($sSession, 2000) EndIf Working in Schoology; optimizing a file uploader script. A window that says "Loading..." will appear on certain actions. I am trying to get the script to detect when this window appears and essentially wait until the window goes away until continuing the next action. The script above seems to work but also seems very delayed. I feel like I am not doing something correctly with the _WD_WaitElement and I am wondering how the "$lVisible" works. ; #FUNCTION# ==================================================================================================================== ; Name ..........: _WD_WaitElement ; Description ...: Wait for a element to be found in the current tab before returning ; Syntax ........: _WD_WaitElement($sSession, $sStrategy, $sSelector[, $iDelay = Default[, $iTimeout = Default[, $lVisible = Default[, ; $lEnabled = Default[, $lReturnElement = Default]]]]]) ; Parameters ....: $sSession - Session ID from _WD_CreateSession ; $sStrategy - Locator strategy. See defined constant $_WD_LOCATOR_* for allowed values ; $sSelector - Value to find ; $iDelay - [optional] Milliseconds to wait before checking status ; $iTimeout - [optional] Period of time to wait before exiting function ; $lVisible - [optional] Check visibility of element? ; $lEnabled - [optional] Check enabled status of element? ; $lReturnElement - [optional] Return found element? ; Return values .: Success - 1 or element ID ; Failure - 0 and sets the @error flag to non-zero ; @error - $_WD_ERROR_Success ; - $_WD_ERROR_Timeout ; Author ........: Dan Pollak ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Thank you for your time and attention to this matter and please have a great day, Thomas Link to comment Share on other sites More sharing options...
Danp2 Posted May 4, 2021 Author Share Posted May 4, 2021 @ThomasBennett You might be able to speed things up a bit by changing your call to _WD_WaitElement so that it returns the found element so that you don't need to call _WD_FindElement afterwards. It appears that you aren't using the latest UDF version, so you may want to update to benefit from the latest fixes. FYI, @mLipok has proposed a change here that may benefit you once it gets approved / merged. ThomasBennett 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
HJL Posted May 4, 2021 Share Posted May 4, 2021 Hello Dan, apparently there is a difference in the $sOption of _WD_Window() and _WD_NewTab() ? _WD_NewTab($sSession, True, -1, $sURL, ', width=1450, height=900') works without the curly braces and without the inner quotes and has a comma in front (it doesn't work with them)._WD_Window($sSession, 'Rect', '{"width":1450, "height":900}'), on the other hand works only with the curly braces and the inner quotes. This irritated me, I've only ever used _WD_NewTab() to assign a size to windows before. Link to comment Share on other sites More sharing options...
Danp2 Posted May 4, 2021 Author Share Posted May 4, 2021 @HJL Sorry that you got irritated by this difference. 🤷♂️ It's basically due to differences in implementation. _WD_Window is passing the parameter directly to the webdriver, which expects the JSON string. _WD_NewTab is using Javascript to open the new window with the designated options, and it won't work with JSON AFAIK. Theoretically, _WD_NewTab could be rewritten to avoid Javascript and use multiple webdriver calls to perform the required actions. However, this isn't something that's planned at this time. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
HJL Posted May 4, 2021 Share Posted May 4, 2021 19 minutes ago, Danp2 said: Theoretically, _WD_NewTab could be rewritten to avoid Javascript and use multiple webdriver calls to perform the required actions. However, this isn't something that's planned at this time. It would help and avoid irritation if there where any short examples for the options in the Functions Docs (for newbies which don't know much about webdriver calls). Nevertheless: you are doing a very good job and I thank you again for making this Webdriver UDF. Link to comment Share on other sites More sharing options...
ThomasBennett Posted May 4, 2021 Share Posted May 4, 2021 (edited) 6 hours ago, Danp2 said: @ThomasBennett You might be able to speed things up a bit by changing your call to _WD_WaitElement so that it returns the found element so that you don't need to call _WD_FindElement afterwards. It appears that you aren't using the latest UDF version, so you may want to update to benefit from the latest fixes. FYI, @mLipok has proposed a change here that may benefit you once it gets approved / merged. @Danp2, Thank you for your help and I think the proposed change by @mLipok will be awesome. Code that resolved my issue: While $x = 1 _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//div[@id='popups-loading']//div[contains(text(),'Loading...')]") $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//div[@id='popups-loading']//div[contains(text(),'Loading...')]") If @error = $_WD_ERROR_Success Then ;MsgBox($MB_SYSTEMMODAL, "Waiting for the Loading... screen to go away.", "Autoclosing this MsgBox", 1) Else SetError($_WD_ERROR_NoMatch) ;MsgBox($MB_SYSTEMMODAL, "Exiting While Loop", "Autoclosing this MsgBox", 5) $x = $x + 1 EndIf WEnd $x = 1 _WD_LoadWait($sSession, 2000) I have a new question; I am trying to read the text "30 of 31" from a Schoology Resources webpage. Once the text is read I will use StringSplit to put what's needed into individual variables and manipulate further from there. I am hung up on how to read the text into a variable. Xpath //thead[@class='tableHeader-processed']//div[@class='collection-paging-info']/ I understand that the code below should allow for the text to be read into a variable //thead[@class='tableHeader-processed']//div[@class='collection-paging-info']/text() I am struggling on how to call this Xpath to read into a variable would I use "_WD_ExecuteScript" for this? Thank you again for your time and consideration, Thomas Edited May 4, 2021 by ThomasBennett I don't know how to use the @ :P Link to comment Share on other sites More sharing options...
Recommended Posts