omarjr16 Posted September 12, 2018 Share Posted September 12, 2018 (edited) #include <wd_core.au3> HotKeySet("{F4}", "iWeirdo") Local $iWeirdo = 1 $_WD_Capabilities = '{"capabilities": {"alwaysMatch": {"chromeOptions": {"w3c": true,"args":["disable-infobars"] }}}}' $_WD_DEBUG = False _WD_Option('Driver', 'chromedriver.exe') _WD_Option('DriverParams', '--verbose --log-path=' & @ScriptDir & '\secretlog-shhhhhh.log') _WD_Option('Port', 9515) _WD_Startup() $sSession = _WD_CreateSession($_WD_Capabilities) do _WD_Navigate($sSession, "https://google.com") $iElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@class='gsfi']") _WD_ElementAction($sSession, $iElement , 'value', "hot 6 years old girls") $ibutton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@value='Google Search']") _WD_ElementAction($sSession, $iElement , 'click') consolewrite("you are added to 'fbi weirdo registry' shame on u danp2") until $iWeirdo = 0 _WD_Window($sSession,'close') _WD_DeleteSession($sSession) _WD_Shutdown() Func iWeirdo() $iWeirdo = 0 Endfunc this simple script need +0.2mb of ram every 3s (no stop) running this awkward function in loop will need 2mb of ram every 1s (depend on ur cpu) no problems in my script fix ur broken udf Func _WD_ClickWaitElement($Session, $Strategy, $Selector, $Timeout, $poi) $hWaitTimer = TimerInit() While 1 $sElement = _WD_FindElement($Session, $Strategy, $Selector) If not @error Then if $poi = 1 then _WD_ElementAction($Session,$sElement,'click') $p = 1 ExitLoop EndIf If TimerDiff($hWaitTimer) > $Timeout Then $p = 0 Exitloop EndIf WEnd Return $p EndFunc Edited September 12, 2018 by omarjr16 Link to comment Share on other sites More sharing options...
Danp2 Posted September 12, 2018 Author Share Posted September 12, 2018 Um.... nope. Don't think I'll be running that script unmodified. P.S. What's with the function you posted? It doesn't appear relevant to the discussion (it isn't being called by the earlier script) P.P.S. How are you measuring the ram usage? And is it growing in the browser, the web driver, or the actual script? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
omarjr16 Posted September 12, 2018 Share Posted September 12, 2018 (edited) using windows task manager + ram growing in the script ...also dont care about the function its an other exemple who take alot more ram then the first script just run the first script and u will see that ram usage will increase by time its small maybe in that one but very big in some other scripts Edited September 12, 2018 by omarjr16 Link to comment Share on other sites More sharing options...
Danp2 Posted September 13, 2018 Author Share Posted September 13, 2018 @omarjr16 Please try again with the latest release and let me know if the memory growth has been reduced. omarjr16 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
omarjr16 Posted September 13, 2018 Share Posted September 13, 2018 (edited) its work correcttly thx again bro Edited September 13, 2018 by omarjr16 Link to comment Share on other sites More sharing options...
grzesiek Posted September 14, 2018 Share Posted September 14, 2018 Do you know how can I in chromedriver use _WD_ElementAction to set the value of an element to value which contains polish letters eg. ąśł? Link to comment Share on other sites More sharing options...
omarjr16 Posted September 14, 2018 Share Posted September 14, 2018 (edited) i want the script to skip"findelement" in case that the page still loading but _WD_FindElement function wait the page until it complete loading then try to find the element ... can _WD_Timeouts or pageLoadStrategy solve this problem? _WD_Timeouts dont work at the moment in chromedriver and idk how to change pageloadstrategy in chrome :c _WD_ExecuteScript($sSession, "location.reload();") ;reload the page _WD_Alert($sSession, 'accept') ;skip alert sleep(2000) _WD_FindElement(...) ; Find An Element . . . Also how to perform keyboard +pointer actions? https://w3c.github.io/webdriver/#perform-actions Edited September 14, 2018 by omarjr16 Link to comment Share on other sites More sharing options...
Danp2 Posted September 14, 2018 Author Share Posted September 14, 2018 3 hours ago, grzesiek said: Do you know how can I in chromedriver use _WD_ElementAction to set the value of an element to value which contains polish letters eg. ąśł? What have you tried? Show us your code and explain exactly what isn't working as expected. Finally, tell us what steps you have tried to troubleshoot the issue, ie -- Have you tried with a different browser? Does your code work with non-unicode text? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Danp2 Posted September 14, 2018 Author Share Posted September 14, 2018 omarjr16 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Danp2 Posted September 14, 2018 Author Share Posted September 14, 2018 3 hours ago, omarjr16 said: Also how to perform keyboard +pointer actions? Using _WD_Action. There's a simple example in wd_demo.au3 omarjr16 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
omarjr16 Posted September 14, 2018 Share Posted September 14, 2018 (edited) thank you again c: but ididnt guess yet how to solve my first problem 5 hours ago, omarjr16 said: i want the script to skip"findelement" in case that the page still loading but _WD_FindElement function wait the page until it complete loading then try to find the element i dont know where to put "pageloadstrategy":"none" in what part ?? '{"capabilities": {"alwaysMatch":{"chromeOptions":{"w3c": true,"args":["disable-infobars","user-data-dir=/Custom/Profile' & $i & '"]}}}}' Edited September 14, 2018 by omarjr16 Link to comment Share on other sites More sharing options...
Danp2 Posted September 14, 2018 Author Share Posted September 14, 2018 45 minutes ago, omarjr16 said: i dont know where to put "pageloadstrategy":"none" in what part ?? I don't remember the exact placement, but I bet you can figure it out quickly with some simple testing. omarjr16 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
grzesiek Posted September 14, 2018 Share Posted September 14, 2018 (edited) 7 hours ago, Danp2 said: What have you tried? Show us your code and explain exactly what isn't working as expected. Finally, tell us what steps you have tried to troubleshoot the issue, ie -- Have you tried with a different browser? Does your code work with non-unicode text? When I add this to the demo script I receive an error 'missing command parameters' and the value is not typed: _WD_ElementAction($sSession, $sElement, 'value', "ąśł") When I don't use polish letters the value is typed. In firefox I also can't type polish letters. To set the value I have to use _WD_ExecuteScript but first I have to change polish characters to codes and prefix them with '\u', for example to enter the letter 'ą': _WD_ExecuteScript($sSession, "document.getElementById('lst-ib').value='\u0105'") But when I want to set the value of a file input element to upload a file I can't set the value through _WD_ExecuteScript so I have to use a path without polish letters to upload a file. Edited September 14, 2018 by grzesiek Link to comment Share on other sites More sharing options...
Danp2 Posted September 14, 2018 Author Share Posted September 14, 2018 @grzesiek I don't have a lot of experience in this area. Perhaps someone else will jump in here with some ideas for you. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
grzesiek Posted September 14, 2018 Share Posted September 14, 2018 I found out how to do this. You have to change in wd_core: Local $sSplitValue = "[" & StringTrimRight(StringRegExpReplace($sOption, '.', '"$0",'), 1) & "]" to Local $sSplitValue = "[" & StringTrimRight(StringRegExpReplace($sOption, '\\u[[:alnum:]]{4}|.', '"$0",'), 1) & "]" so the character codes wouldn't be splitted. Also maybe would be better to change non ASCII characters to codes internally in the UDF. duzers and mLipok 1 1 Link to comment Share on other sites More sharing options...
Danp2 Posted September 14, 2018 Author Share Posted September 14, 2018 @grzesiek Thanks... I'll take a look at this later. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
grzesiek Posted September 15, 2018 Share Posted September 15, 2018 Also when I want to type the '\' character it needs to be doubled so I need to enter '\\'. So you have to change to: Local $sSplitValue = "[" & StringTrimRight(StringRegExpReplace($sOption, '\\\\|\\u[[:alnum:]]{4}|.', '"$0",'), 1) & "]" mLipok and duzers 1 1 Link to comment Share on other sites More sharing options...
Danp2 Posted September 15, 2018 Author Share Posted September 15, 2018 I've been doing some testing on this and want to be sure that we make the correct change. Can someone explain why I get the same result for the two split string values? #include <MsgBoxConstants.au3> Local $sSplitValue, $sSplitValue2 Local $sOption = 'ąśł' MsgBox($MB_SYSTEMMODAL, "Original", $sOption) $sSplitValue = "[" & StringTrimRight(StringRegExpReplace($sOption, '.', '"$0",'), 1) & "]" $sSplitValue2 = "[" & StringTrimRight(StringRegExpReplace($sOption, '\\u[[:alnum:]]{4}|.', '"$0",'), 1) & "]" MsgBox($MB_SYSTEMMODAL, "Split", $sSplitValue & @crlf & $sSplitValue2) Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Danp2 Posted September 15, 2018 Author Share Posted September 15, 2018 AFAICS, the issue isn't with the StringRegExpReplace in _WD_ElementAction. Rather, it is with the _WinHttpSendRequest call in __WD_Post. _WinHttpSendRequest creates a byte array structure and stores the string into this array. It's at this point that the unicode characters are getting "lost". Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Danp2 Posted September 15, 2018 Author Share Posted September 15, 2018 @grzesiek I believe that I have found the correct way to address the issue. Please change the following line in __WD_Post from $sResponseText = _WinHttpSimpleRequest($hConnect, "POST", $aURL[6], Default, $sData) to $sResponseText = _WinHttpSimpleRequest($hConnect, "POST", $aURL[6], Default, StringToBinary($sData, 4)) and then retest with the Polish text. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Recommended Posts