drr Posted September 5, 2020 Share Posted September 5, 2020 4 hours ago, Danp2 said: In this situation, you have to pass the attribute or property name using the proper case. The process is returning a Null because it can't find an attribute named "innerhtml". Change this to "innerHTML" and it should give you the desired result. Thanks Danp2! This solved the issue 👍 Link to comment Share on other sites More sharing options...
jbnet Posted September 7, 2020 Share Posted September 7, 2020 (edited) On 12/15/2019 at 12:38 AM, jbnet said: Gostaria de saber se é possível acessar esses recursos de rede após carregar a página no firefox conforme definido na imagem com o webdriver Tentei enviar o comando javascript, enviar sequência de cabeçalho mas com minha pouca experiência não consegui obter esses dados como a imagem, mas quero que ele recupere os dados como exemplo na imagem, essa lista de pedidos, mas não sei como fazer. Agradeço esse trabalho, gosto muito desse udf. Danp2 I had asked you this question, but you didn't understand, I wanted to get the network data that was in firefox, based on the stackoverflow website https://stackoverflow.com/questions/45847035/using-selenium-how-to-get-network-request, I did it using javascript, but it shows how to do it with seleneium webdriver, using javascript and java, but looking at the site, would you have an idea of how to implement in autoit using webdriver without javascript? Edited September 7, 2020 by jbnet Link to comment Share on other sites More sharing options...
Danp2 Posted September 7, 2020 Author Share Posted September 7, 2020 @jbnetThere are multiple solutions offered in that thread. Which one did you want to implement? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
jbnet Posted September 7, 2020 Share Posted September 7, 2020 So I use your script more, my knowledge is little to implement, but the data I use is, for example, the link I get on the network, xhr, where I can't find it on the page, an example I'm using, in json format then I look for what I need inside. $txt =_WD_ExecuteScript($sSession, _ "var performance = window.performance || window.mozPerformance || window.msPerformance || window.webkitPerformance || {}; var network = performance.getEntries() || {}; return JSON.stringify(network);" ) ;clipPut($txt) Local $obJson = Json_Decode($txt) $obJson = Json_Decode(Json_ObjGet($obJson, "value")) Link to comment Share on other sites More sharing options...
Danp2 Posted September 7, 2020 Author Share Posted September 7, 2020 I'm not aware of another way to obtain this information. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
frank10 Posted September 18, 2020 Share Posted September 18, 2020 (edited) #include "wd_helper.au3" #include "wd_core.au3" #AutoIt3Wrapper_UseX64=Y OnAutoItExitRegister("_onExit") $_WD_DEBUG = True ; You could also use $_WD_DEBUG_Error _WD_Option('Driver', 'chromedriver.exe') _WD_Option('Port', 9515) _WD_Option('DriverParams', '--log-path=' & @ScriptDir & '\chrome.log') $sDesiredCapabilitiesNoSecurNoConsole = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["--disable-web-security", "--incognito", "--user-data-dir=C:\\Temp", "--profile-directory=Default"]}}}}' _WD_Startup() If @error <> $_WD_ERROR_Success Then MsgBox(0,'','error') global $sSession = _WD_CreateSession($sDesiredCapabilitiesNoSecurNoConsole) ;~ session not created: This version of ChromeDriver only supports Chrome Exit Func _onExit() ConsoleWrite("####") _WD_DeleteSession($sSession) ConsoleWrite("deleteSess: " & @error & " " & @extended & @CRLF) _WD_Shutdown() EndFunc ; end onexit _WDStartup: OS: WIN_10 WIN32_NT 18362 _WDStartup: AutoIt: 3.3.14.5 _WDStartup: WD.au3: 0.3.0.8 (Update available) _WDStartup: WinHTTP: 1.6.3.9 (Download latest source at <https://raw.githubusercontent.com/dragana-r/autoit-winhttp/master/WinHttp.au3>) _WDStartup: Driver: chromedriver.exe It seems there is a problem with _WD_DeleteSession it does not execute the next _WD_Shutdown (neither the Consolewrite after the Delete...)! I found it blocks on __WD_DetectError on this line: Local $oJSON = Json_Decode($vResult) ( $vResult is {"value":null} ) and in the Json_Decode func at the line: DllCallAddress("none:cdecl", $Jsmn_Init, "ptr", DllStructGetPtr($Parser)) it seems it crashes the script... EDIT: I don't know why the editor does not align the text correctly... sorry (in the preview is correct) Edited September 18, 2020 by Melba23 Fixed formatting Link to comment Share on other sites More sharing options...
Danp2 Posted September 18, 2020 Author Share Posted September 18, 2020 59 minutes ago, frank10 said: _WDStartup: WinHTTP: 1.6.3.9 (Download latest source at <https://raw.githubusercontent.com/dragana-r/autoit-winhttp/master/WinHttp.au3>) This is here for your benefit. Please follow the directive and then retest once you are on v1.6.4.2. P.S. Since you aren't running v1.6.4.1, I would recommend installing that first and then grab the latest source at the link above Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Danp2 Posted September 18, 2020 Author Share Posted September 18, 2020 1 hour ago, frank10 said: It seems there is a problem with _WD_DeleteSession it does not execute the next _WD_Shutdown (neither the Consolewrite after the Delete...)! This isn't an area where I have a ton of experience, but I'm guessing that this is a timing issue with the _onExit function being called after some global variables have been destroyed. Perhaps someone else will jump in with some ideas on how this can be resolved. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
frank10 Posted September 18, 2020 Share Posted September 18, 2020 (edited) Ok, I installed it but same result: It closes Chrome browser, but does not close the chromedriver.exe console opened Thank you, let's see if we can solve this. Edited September 18, 2020 by frank10 Link to comment Share on other sites More sharing options...
frank10 Posted September 18, 2020 Share Posted September 18, 2020 (edited) You're right, in fact if I put the same _onExit content instead of Exit, it works well! So the problem should be in OnAutoItExitRegister("_onExit") and the call of that func. Edited September 18, 2020 by frank10 Danp2 1 Link to comment Share on other sites More sharing options...
Danp2 Posted September 18, 2020 Author Share Posted September 18, 2020 FWIW, I'm seeing the same issue when using OnAutoItExitRegister with _WD_Delete -- AutoIt3.exe ended.rc:-1073741819 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Danp2 Posted September 18, 2020 Author Share Posted September 18, 2020 @frank10 and anyone else interested, Here's a simple reproducer script -- #include <JSON.au3> ; https://www.autoitscript.com/forum/topic/148114-a-non-strict-json-udf-jsmn #AutoIt3Wrapper_UseX64=Y OnAutoItExitRegister("_onExit") Demo() Sleep(2000) Func _onExit() Demo() EndFunc Func Demo() Local $sJSON = '{"value":null}' ConsoleWrite("pre Json_Decode" & @CRLF) Local $oJSON = Json_Decode($sJSON) ConsoleWrite("post Json_Decode" & @CRLF) EndFunc If you comment out the call to Demo() in the main script, then the crash no longer occurs. Guessing that it has something to do with the static variable usage,. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
TheXman Posted September 18, 2020 Share Posted September 18, 2020 (edited) 2 hours ago, Danp2 said: If you comment out the call to Demo() in the main script, then the crash no longer occurs. It also does not occur if you move the registering of _OnExit() AFTER Demo() in the main script. It looks like as long as OnAutoITExitRegister() is NOT the first function called in the script, it works fine. #include <JSON.au3> Demo() OnAutoItExitRegister("_onExit") Demo() Func _onExit() Demo() EndFunc Func Demo() Local $sJSON = '{"value":null}' ConsoleWrite("pre Json_Decode" & @CRLF) Local $oJSON = Json_Decode($sJSON) ConsoleWrite("post Json_Decode" & @CRLF) EndFunc Edited September 18, 2020 by TheXman Danp2 1 CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
Danp2 Posted September 18, 2020 Author Share Posted September 18, 2020 @Danyfirex has identified that the issue originates in the BinaryCall UDF, which gets called by the JSON UDF. It registers an OnAutoITExitRegister function, that is freeing resources before the main OnAutoITExitRegister function gets executed. @TheXman Your example works because it registers the BinaryCall exit routine before the main OnAutoITExitRegister routine is registered, so exit events now occur in the desired order. You can also accomplish this by adding the following before calling OnAutoITExitRegister Json_Decode("") Will release an update to the UDF once we come up with a more permanent fix. frank10 and TheXman 1 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
ahmet Posted September 19, 2020 Share Posted September 19, 2020 (edited) Hello, I am trying to run two different scripts using chrome webdriver. Apps are run from different folders using different locations for chromedriver.exe. These are apps for testing. They will only navigate to different pages. After I start second app first one closes immediately if I use same port. If I change one port to something different than 9515, i.e. 4444, then I get following output: _WD_IsLatestRelease: True _WD_IsLatestRelease ==> Success _WDStartup: OS: WIN_10 WIN32_NT 18362 _WDStartup: AutoIt: 3.3.14.5 _WDStartup: WD.au3: 0.3.0.9 (Up to date) _WDStartup: WinHTTP: 1.6.4.2 _WDStartup: Driver: chromedriver.exe _WDStartup: Params: _WDStartup: Port: 4444 __WD_Post: URL=HTTP://127.0.0.1:4444/session; $sData={"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true }}}} __WD_Post: StatusCode=0; ResponseText=WinHTTP request timed out before Webdriver... __WD_Post ==> Send / Recv error: WinHTTP request timed out before Webdriver _WD_CreateSession: WinHTTP request timed out before Webdriver _WD_CreateSession ==> Webdriver Exception: HTTP status = 0 create session:10 I am also attaching screenshot of chromedriver window. As can be seen it shows "Starting... on port 9515" altough something else is defined in script. app1.au3 app2.au3 Edited September 19, 2020 by ahmet Link to comment Share on other sites More sharing options...
Danp2 Posted September 19, 2020 Author Share Posted September 19, 2020 @ahmet You've actually only told the UDF which port to communicate on with the webdriver. You need to give the webdriver specific instructions to start on a different port using additions to your 'DriverParams' settitngs. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
ahmet Posted September 20, 2020 Share Posted September 20, 2020 (edited) @Danp2 Thank you. This is the code I used _WD_Option('DriverParams', '--port=9815') It did start webdriver on different port, but the chromedriver.exe's window kept closing as soon as I launch second app, so I was only able to use one app. I solved it by renaming one of chromedriver.exe files to something else, test.exe in this case, and then they are running well. I am also using different ports. Edit: If I use same ports, but rename one of chromedriver.exe files then two scripts also work. Edited September 20, 2020 by ahmet Link to comment Share on other sites More sharing options...
Danp2 Posted September 20, 2020 Author Share Posted September 20, 2020 @ahmet I forgot to mention that this is the default behavior and there are additional setttings that you will need to adjust. Add this to the beginning of your script to prevent it from closing an existing webdriver instance and force it to launch a second instance -- _WD_Option("driverclose", False) _WD_Option("driverdetect", False) Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
ahmet Posted September 20, 2020 Share Posted September 20, 2020 Thank you, it is working as intended. Link to comment Share on other sites More sharing options...
Jemboy Posted September 25, 2020 Share Posted September 25, 2020 I dread every time I have edit the "capabilities" when I am using the Chromedriver. Is there some clear explanation with plenty😁 of examples available ? Big Wish: is there an app or a website where one could just select the capabilities and the string would be created to copy to AutoIt ? Link to comment Share on other sites More sharing options...
Recommended Posts