Shogi Posted September 26, 2018 Share Posted September 26, 2018 Sorry For Asking alot what Capabilities i must use with operadriver Link to comment Share on other sites More sharing options...
Danp2 Posted September 26, 2018 Author Share Posted September 26, 2018 @Shogi Like I said before -- On 9/25/2018 at 11:59 AM, Danp2 said: You can't expect to come here and have someone spoon feed the answers to you Do your own research, then post some code to show us what you have tried thus far. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Danp2 Posted September 26, 2018 Author Share Posted September 26, 2018 (edited) Here's an example showing how to inject jQuery into the active website -- expandcollapse popup#include "wd_core.au3" Local Enum $eFireFox = 0, _ $eChrome Local Const $_TestType = $eChrome Local $sDesiredCapabilities Local $sText Local $sSession $_WD_DEBUG = $_WD_DEBUG_Info Switch $_TestType Case $eFireFox SetupGecko() Case $eChrome SetupChrome() EndSwitch _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, "https://google.com") _WD_jQuerify($sSession) _WD_ExecuteScript($sSession, "jQuery('input[name=\""q\""]').val('bada-bing').closest('form').submit();") ; #FUNCTION# ==================================================================================================================== ; Name ..........: _WD_jQuerify ; Description ...: Inject jQuery library into current session ; Syntax ........: _WD_jQuerify($sSession) ; Parameters ....: $sSession - Session ID from _WDCreateSession ; Return values .: None ; Author ........: Dan Pollak ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: https://sqa.stackexchange.com/questions/2921/webdriver-can-i-inject-a-jquery-script-for-a-page-that-isnt-using-jquery ; Example .......: No ; =============================================================================================================================== Func _WD_jQuerify($sSession) Local $jQueryLoader = _ "(function(jqueryUrl, callback) {" & _ " if (typeof jqueryUrl != 'string') {" & _ " jqueryUrl = 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js';" & _ " }" & _ " if (typeof jQuery == 'undefined') {" & _ " var script = document.createElement('script');" & _ " var head = document.getElementsByTagName('head')[0];" & _ " var done = false;" & _ " script.onload = script.onreadystatechange = (function() {" & _ " if (!done && (!this.readyState || this.readyState == 'loaded' " & _ " || this.readyState == 'complete')) {" & _ " done = true;" & _ " script.onload = script.onreadystatechange = null;" & _ " head.removeChild(script);" & _ " callback();" & _ " }" & _ " });" & _ " script.src = jqueryUrl;" & _ " head.appendChild(script);" & _ " }" & _ " else {" & _ " jQuery.noConflict();" & _ " callback();" & _ " }" & _ "})(arguments[0], arguments[arguments.length - 1]);" _WD_ExecuteScript($sSession, $jQueryLoader, "[]", True) Do Sleep(250) _WD_ExecuteScript($sSession, "jQuery") Until @error = $_WD_ERROR_Success EndFunc Func SetupGecko() _WD_Option('Driver', 'geckodriver.exe') _WD_Option('DriverParams', '--log trace') _WD_Option('Port', 4444) $sDesiredCapabilities = '{"desiredCapabilities":{"javascriptEnabled":true,"nativeEvents":true,"acceptInsecureCerts":true}}' EndFunc Func SetupChrome() _WD_Option('Driver', 'chromedriver.exe') _WD_Option('Port', 9515) _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"chromeOptions": {"w3c": true }}}}' EndFunc You likely will need to grab the latest (unreleased) version of the UDF from Github, since this uses a recent change to _WD_ExecuteScript. Appreciate any feedback / suggestions. Edited September 27, 2018 by Danp2 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
caramen Posted September 29, 2018 Share Posted September 29, 2018 (edited) nvm Edited September 29, 2018 by caramen My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki Link to comment Share on other sites More sharing options...
Shogi Posted September 29, 2018 Share Posted September 29, 2018 (edited) I want to make a bot who do some actions when u type a command in youtube live stream chat i want him to get text from the last message <yt-live-chat-text-message-renderer class="style-scope yt-live-chat-item-list-renderer" id="CjkKGkNOVEZpWS1yNE4wQ0ZRMXNtQW9kdGtJUDlREhtDTWJfbmN5WDROMENGUks5V0FvZE5wVUQwZzY%3D" author-type=""> all the messages looks like this but with diffrent id and they are putted in a list with x maximum messages .. u can check that urself just type "24/7 livestream" in youtube search bar is there anyway to find the last message ? Edited September 29, 2018 by Shogi Link to comment Share on other sites More sharing options...
Danp2 Posted September 29, 2018 Author Share Posted September 29, 2018 @Shogi The following works with Firefox, but it errors out on Chrome on the _WD_ElementAction command -- expandcollapse popup#include "wd_core.au3" #include "wd_helper.au3" Local Enum $eFireFox = 0, _ $eChrome Local Const $_TestType = $eFireFox Local $sDesiredCapabilities Local $sText = "" Local $sSession $_WD_DEBUG = $_WD_DEBUG_Info Switch $_TestType Case $eFireFox SetupGecko() Case $eChrome SetupChrome() EndSwitch _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, "https://www.youtube.com/watch?v=ghTLdWpANeA") _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//iframe[@id='chatframe']", 2000, 3000) If @error = $_WD_ERROR_Success Then _WD_FrameEnter($sSession, 1) _WD_WaitElement($sSession, $_WD_LOCATOR_ByTagName, "yt-live-chat-text-message-renderer", 1000, 5000) If @error = $_WD_ERROR_Success Then $aElements = _WD_FindElement($sSession, $_WD_LOCATOR_ByTagName, "yt-live-chat-text-message-renderer", "", True) If @error = $_WD_ERROR_Success Then $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "div[@id='content']/span[@id='message']", $aElements[UBound($aElements)-1]) $sText = _WD_ElementAction($sSession, $sElement, 'property', 'innerText') EndIf _WD_FrameLeave($sSession) ConsoleWrite("Last comment = " & $sText & @CRLF) EndIf EndIf Func SetupGecko() _WD_Option('Driver', 'geckodriver.exe') _WD_Option('DriverParams', '--log trace') _WD_Option('Port', 4444) $sDesiredCapabilities = '{"desiredCapabilities":{"javascriptEnabled":true,"nativeEvents":true,"acceptInsecureCerts":true}}' EndFunc Func SetupChrome() _WD_Option('Driver', 'chromedriver.exe') _WD_Option('Port', 9515) _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"chromeOptions": {"w3c": true }}}}' EndFunc Shogi 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Shogi Posted September 30, 2018 Share Posted September 30, 2018 (edited) i have a problem :c when i change the profile it cant connect to the the browser $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"moz:firefoxOptions": {"args": ["-profile", "C:\\Users\\Admin\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\8eg9dycr.default"]}},"javascriptEnabled":true,"nativeEvents":true,"acceptInsecureCerts":true,"pageLoadStrategy":"none"}}' _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, "https://www.youtube.com/watch?v=ghTLdWpANeA") 1538265504386 webdriver::server DEBUG -> POST /session {"capabilities": {"alwaysMatch": {"moz:firefoxOptions": {"args": ["-profile", "C:\\Users\\Admin\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\8eg9dycr.default"]}},"javascriptEnabled":true,"nativeEvents":true,"acceptInsecureCerts":true,"pageLoadStrategy":"none"}} 1538265504401 mozrunner::runner INFO Running command: "C:\\Program Files\\Mozilla Firefox\\firefox.exe" "-marionette" "-profile" "C:\\Users\\Admin\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\8eg9dycr.default" "-foreground" "-no-remote" 1538265504401 geckodriver::marionette DEBUG Waiting 60s to connect to browser on 127.0.0.1:62417 Edited September 30, 2018 by Shogi Link to comment Share on other sites More sharing options...
Danp2 Posted September 30, 2018 Author Share Posted September 30, 2018 Have you tried this? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Shogi Posted September 30, 2018 Share Posted September 30, 2018 (edited) i used --marionette-port 2828 option and it worked perfectly thank you Edited September 30, 2018 by Shogi Link to comment Share on other sites More sharing options...
Shogi Posted October 1, 2018 Share Posted October 1, 2018 when iconnect to any google account your script stop working __WD_Post: URL=HTTP://127.0.0.1:4444/session/95f4ce3c-3bec-4545-aa43-b007a990b68f/elements; $sData={"using":"tag name","value":"yt-live-chat-text-message-renderer"} __WD_Post: StatusCode=200; ResponseText={"value":[]} _WD_FindElement: {"value":[]} _WD_FindElement ==> No match: HTTP status = 200 On 29/09/2018 at 1:45 PM, Danp2 said: expandcollapse popup#include "wd_core.au3" #include "wd_helper.au3" Local Enum $eFireFox = 0, _ $eChrome Local Const $_TestType = $eFireFox Local $sDesiredCapabilities Local $sText = "" Local $sSession $_WD_DEBUG = $_WD_DEBUG_Info Switch $_TestType Case $eFireFox SetupGecko() Case $eChrome SetupChrome() EndSwitch _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, "https://www.youtube.com/watch?v=ghTLdWpANeA") _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//iframe[@id='chatframe']", 2000, 3000) If @error = $_WD_ERROR_Success Then _WD_FrameEnter($sSession, 1) _WD_WaitElement($sSession, $_WD_LOCATOR_ByTagName, "yt-live-chat-text-message-renderer", 1000, 5000) If @error = $_WD_ERROR_Success Then $aElements = _WD_FindElement($sSession, $_WD_LOCATOR_ByTagName, "yt-live-chat-text-message-renderer", "", True) If @error = $_WD_ERROR_Success Then $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "div[@id='content']/span[@id='message']", $aElements[UBound($aElements)-1]) $sText = _WD_ElementAction($sSession, $sElement, 'property', 'innerText') EndIf _WD_FrameLeave($sSession) ConsoleWrite("Last comment = " & $sText & @CRLF) EndIf EndIf Func SetupGecko() _WD_Option('Driver', 'geckodriver.exe') _WD_Option('DriverParams', '--log trace') _WD_Option('Port', 4444) $sDesiredCapabilities = '{"desiredCapabilities":{"javascriptEnabled":true,"nativeEvents":true,"acceptInsecureCerts":true}}' EndFunc Func SetupChrome() _WD_Option('Driver', 'chromedriver.exe') _WD_Option('Port', 9515) _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"chromeOptions": {"w3c": true }}}}' EndFunc Link to comment Share on other sites More sharing options...
Danp2 Posted October 1, 2018 Author Share Posted October 1, 2018 @Shogi You'll need to be more specific. What do you mean by "connect to any google account"? Also, you need to perform more troubleshooting on your own. Figure out what has changed in the website's HTML. Why aren't the yt-live-chat-text-message-renderer tags being found? It probably has something to do with the _WD_FrameEnter command. Perhaps the site layout differs when logged into a google account and that command is now pointing to the incorrect frame. This is something you should be able to fix on your own. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Shogi Posted October 2, 2018 Share Posted October 2, 2018 (edited) i didnt notice any diffrence in the frame also i dont need to login to an google account for this to happen ... your script only work if you are opening youtube for the first time in the session :c the script below prove that if you open youtube before you go to the live stream the script fail :c $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, "https://www.youtube.com/") _WD_Navigate($sSession, "https://www.youtube.com/watch?v=ghTLdWpANeA") Edited October 2, 2018 by Shogi Link to comment Share on other sites More sharing options...
Danp2 Posted October 2, 2018 Author Share Posted October 2, 2018 As I suspected, it was an issue with the _WD_FrameEnter command. Change this line -- _WD_FrameEnter($sSession, 1) to $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//iframe[@id='chatframe']") _WD_FrameEnter($sSession, $sElement) and it should work properly again. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Shogi Posted October 2, 2018 Share Posted October 2, 2018 thank you i understand now why you put that 1 in the first script :3 Link to comment Share on other sites More sharing options...
BigDaddyO Posted October 2, 2018 Share Posted October 2, 2018 (edited) Just putting this out there since I just spent far to many hours figuring out the problem. I added an Issue to the Chromedriver site about this. if your working in a corporate Environment and they have turned on the chrome policy (DeveloperToolsDisabled) = 1, then if you upgrade to Chrome 69, chromedriver will no longer work. You may see the following error in your chrome.log file: [SEVERE]: Unable to receive message from renderer The issue is caused by Chrome 69 having a new policy (DeveloperToolsAvailability) which has 3 levels. 0, 1, 2. 0 blocks some stuff, 1 blocks nothing, 2 blocks everything. If Chrome 69 sees the older depreciated policy then it will act as if the option 2 was set in the new policy. Only fix that I know of now, is to delete the old depreciated policy, then add the new policy with the 0 or 1 option. Edited October 2, 2018 by BigDaddyO Link to comment Share on other sites More sharing options...
SecreTel Posted October 3, 2018 Share Posted October 3, 2018 Thank BigDaddy for your info ! I discover Chromedriver and I think I have the problem that you describe I start with the file wd_demo.au3 provided in the WebDriver-0.1.0.15 installation. WD_Startup opens the command window and waits indefinitely.Starting ChromeDriver 2.42.591088 (7b2b2dca23cca0862f674758c9a3933e685c27d5) on port 9515 Only local connections are allowed. I have to manually close the window and the script to continue. The Run() command of _WD_Startup () returns a $pid > 0 without error, but I think the effect of closing command window exit ChromeDriver ? So after not possible to CreateSession() How to change DeveloperToolsAvailability in Chrome ? Thanks Link to comment Share on other sites More sharing options...
PaulC Posted October 4, 2018 Share Posted October 4, 2018 Can you help me an example about request Google Cloud Compute: read instance info, start/stop instance using GCP API? Link to comment Share on other sites More sharing options...
Danp2 Posted October 4, 2018 Author Share Posted October 4, 2018 @PaulC This UDF is designed to automate a web browser. Unsure why you would want to use it to interact with GCP API. Please explain. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
SecreTel Posted October 4, 2018 Share Posted October 4, 2018 (edited) The demo file wd_demo.au3 shows us how to insert value and click in text input, but not click on a button. So I add it in the code, but doesn't work. I expect, the browser change the page and show me the result for fujimo ! Func DemoNavigation() _WD_Navigate($sSession, "http://google.com") .... _WD_ElementAction($sSession, $sElement, 'value', "fujimo") Sleep(500) _WD_ElementAction($sSession, $sElement, 'text') _WD_ElementAction($sSession, $sElement, 'click') ;<--- Clic on the text input $sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@name='btnK']") ConsoleWrite("Button Ref: " & $sButton & @CRLF) ConsoleWrite("Befor Click" & @CRLF) _WD_ElementAction($sSession, $sButton, 'click') ;< Sleep(2000) ConsoleWrite("After Click" & @CRLF) Console Button Ref: bf3b458e-af44-47b4-b5d6-58d5d03bde2c Befor Click __WD_Post: URL=HTTP://127.0.0.1:9515/session/e6a2311e673b1d027774a4ccfc75bafa/element/bf3b458e-af44-47b4-b5d6-58d5d03bde2c/click; $sData={"id":"bf3b458e-af44-47b4-b5d6-58d5d03bde2c"} __WD_Post: StatusCode=500; ResponseText={"value":{"error":"unknown error","message":"Element \u003Cinput value=\"Buscar con Google\" aria-label=\"Buscar con Google\" name=\"btnK\" type=\"submit\" jsaction=\"sf.chk\"> is not clickable at point (429, 411). Other element would receive the click\u003Cdiv class=\"sbqs_c\">...\u003C/div>(Session infochrome=69.0.3497.100)","stacktrace":"Backtrace:\n\tOrdinal0 [0x00F8AA90+830096]\n\tOrdinal0 [0x00F3581D+481309]\n\tOrdinal0 [0x00F0AC47+306247]\n\tOrdinal0 [0x00EDB23E+111166]\n\tOrdinal0 [0x00EDAEEE+110318]\n\tOrdinal0 [0x00ED9578+103800]\n\tOrdinal0 [0x00ED8EA6+102054]\n\tOrdinal0 [0x00ED5134+86324]\n\tOrdinal0 [0x00EEAA9D+174749]\n\tOrdinal0 [0x00ED4E28+85544]\n\tOrdinal0 [0x00EEAD31+175409]\n\tOrdinal0 [0x00EF208B+204939]\n\tOrdinal0 [0x00EEA93B+174395]\n\tOrdinal0 [0x00ED2D54+77140]\n\tOrdinal0 [0x00ED430C+82700]\n\tOrdinal0 [0x00ED4260+82528]\n\tOrdinal0 [0x00F95302+873218]\n\tOrdinal0 [0x00F40553+525651]\n\tOrdinal0 [0x00F40783+526211]\n\tOrdinal0 [0x00F4086C+526444]\n\tOrdinal0 [0x00F983A7+885671]\n\tOrdinal0 [0x00F403BF+525247]\n\tOrdinal0 [0x00F4A60E+566798]\n\tOrdinal0 [0x00F55DDB+613851]\n\tOrdinal0 [0x00F55F45+614213]\n\tOrdinal0 [0x00F55175+610677]\n\tBaseThreadInitThunk [0x76408674+36]\n\tRtlGetAppContainerNamedObjectPath [0x77925D87+311]\n\tRtlGetAppContainerNamedObjectPath [0x77925D57+263]\n"}} _WD_ElementAction: {"value":{"error":"unknown error","message":"Element \u003Cinput value=\"Buscar con Google\" aria-label=\"Buscar con Google\" name=\"btnK\" type=\"submit\" jsaction=\"sf.chk\"> is not clickable at point (429, 411). Other element would receive the click\u003Cdiv class=\"sbqs_c\">...\u003C/div>(Session infochrome=69.0.3497.100)","stacktrace":"Backtrace:\n\tOrdinal0 [0x00F8AA90+830096]\n\tOrdinal0 [0x00F3581D+481309]\n\tOrdinal0 [0x00F0AC47+306247]\n\tOrdinal0 [0x00EDB23E+111166]\n\tOrdinal0 [0x00EDAEEE+110318]\n\tOrdinal0 [0x00ED9578+103800]\n\tOrdinal0 [0x00ED8EA6+102054]\n\tOrdinal0 [0x00ED5134+86324]\n\tOrdinal0 [0x00EEAA9D+174749]\n\tOrdinal0 [0x00ED4E28+85544]\n\tOrdinal0 [0x00EEAD31+175409]\n\tOrdinal0 [0x00EF208B+204939]\n\tOrdinal0 [0x00EEA93B+174395]\n\tOrdinal0 [0x00ED2D54+77140]\n\tOrdinal0 [0x00ED430C+82700]\n\tOrdinal0 [0x00ED4260+82528]\n\tOrdinal0 [0x00F95302+873218]\n\tOrdinal0 [0x00F40553+525651]\n\tOrdinal0 [0x00F40783+526211]\n\tOrdinal0 [0x00F4086C+526444]\n\tOrdinal0 [0x00F983A7+885671]\n\tOrdinal0 [0x00F403BF+525247]\n\tOrdinal0 [0x00F4A60E+566798]\n\tOrdinal0 [0x00F55DDB+613851]\n\tOrdinal0 [0x00F55F45+614213]\n\tOrdinal0 [0x00F55175+610677]\n\tBaseThreadInitThunk [0x76408674+36]\n\tRtlGetAppContainerNamedObjectPath [0x77925D87+311]\n\tRtlGetAppContainerNamedObjectPath [0x77925D57+263]\n"}} After Click Edited October 4, 2018 by SecreTel Link to comment Share on other sites More sharing options...
Danp2 Posted October 4, 2018 Author Share Posted October 4, 2018 Seems like Google changed their page layout, so some of the prior code is failing. Once I fixed that, then your code ran fine for me. FWIW, I changed "//input[@id='lst-ib']" to "//input[@name='q']". Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Recommended Posts