horphi Posted May 24, 2018 Share Posted May 24, 2018 2 hours ago, grzesiek said: @horphi Try this: _WD_ExecuteScript($sSession, 'document.getElementsByTagName('p')[1].select();') I tried this already...works unfortunately not...:-( _WD_ExecuteScript: {"value":{"error":"javascript error","message":"TypeError: document.getElementsByTagName(...)[1].select --> is not a function","stacktrace":"execute_script @, line 0\ninline javascript, line 1\nsrc: \"undefined\"\nStack:\n Link to comment Share on other sites More sharing options...
grzesiek Posted May 24, 2018 Share Posted May 24, 2018 I think the select method is for the input elements. Link to comment Share on other sites More sharing options...
horphi Posted May 24, 2018 Share Posted May 24, 2018 (edited) moved to help & support Edited May 25, 2018 by horphi Link to comment Share on other sites More sharing options...
horphi Posted May 27, 2018 Share Posted May 27, 2018 Maybe some minor hint to _WD_NewTab A error occurs if no browser is opend and the script interrupt. expandcollapse popupFunc _WD_NewTab($sSession, $lSwitch = True) Local Const $sFuncName = "_WD_NewTab" Local $sTabHandle = '' _WD_ExecuteScript($sSession, 'window.open()', '{}') If @error = $_WD_ERROR_Success Then Local $aHandles = _WD_Window($sSession, 'handles', '') $sTabHandle = $aHandles[UBound($aHandles) - 1] ;<<<<<<<<<<<<<<<<<<<<<<If this is no array, script interrupt If $lSwitch Then _WD_Window($sSession, 'Switch', '{"handle":"' & $sTabHandle & '"}') EndIf EndIf Return SetError($_WD_ERROR_Success, 0, $sTabHandle) EndFunc Func _WD_NewTab($sSession, $lSwitch = True) Local Const $sFuncName = "_WD_NewTab" Local $sTabHandle = '' _WD_ExecuteScript($sSession, 'window.open()', '{}') If @error = $_WD_ERROR_Success Then Local $aHandles = _WD_Window($sSession, 'handles', '') If IsArray($aHandles) Then $sTabHandle = $aHandles[UBound($aHandles) - 1] Else ConsoleWrite("> An error occurred. " & 'No Session exist.' & @CRLF) EndIf If $lSwitch Then _WD_Window($sSession, 'Switch', '{"handle":"' & $sTabHandle & '"}') EndIf EndIf Return SetError($_WD_ERROR_Success, 0, $sTabHandle) EndFunc Link to comment Share on other sites More sharing options...
Danp2 Posted May 27, 2018 Author Share Posted May 27, 2018 (edited) @horphi Probably need to check the value of @error after the call to _WD_Window. I'll have to do some testing, but would have thought that the earlier call to _WD_ExecuteScript would have failed. Edit: Fixed _WD_ExecuteScript so that it properly sets @error Edited May 27, 2018 by Danp2 horphi 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
jasperhale Posted May 27, 2018 Share Posted May 27, 2018 Sorry if i dont read all of comment (if there are the answers before) Can you teach me how to set proxy / socks with this UDF ? Thanks for reading @Danp2 Link to comment Share on other sites More sharing options...
Danp2 Posted May 27, 2018 Author Share Posted May 27, 2018 @jasperhale I have not done any work in this area. Suggest that you research and let us know if you come up with a solution. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
mLipok Posted May 27, 2018 Share Posted May 27, 2018 @jasperhale Quick Search: https://stackoverflow.com/questions/11450158/how-do-i-set-proxy-for-chrome-in-python-webdriver?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa https://thefriendlytester.co.uk/2014/10/set-proxy-using-webdriver.html http://chromedriver.chromium.org/capabilities Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
Danyfirex Posted June 16, 2018 Share Posted June 16, 2018 Hello. Tested with Microsoft WebDriver (version 16299). Here the Setup Function Func SetupEdge() _WD_Option('Driver', 'MicrosoftWebDriver-16299.exe') _WD_Option('Port', 17556) EndFunc _WD_CreateSession need to be modified becuase the sessionid is not returned here [value][sessionId] It's retuned here [sessionId] That's all I tested just few commands navigate,FindElement,Action But I think all will work correctly. Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
Danp2 Posted June 16, 2018 Author Share Posted June 16, 2018 @Danyfirex Thanks for the feedback. I'll take a look at this when I get a chance. Unsure at this point which implementation is correct as far as the W3C standards. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Danp2 Posted June 17, 2018 Author Share Posted June 17, 2018 Looks like the upcoming update to the Microsoft web driver will implement the updated W3C spec. In the interim, I can update the UDF to correctly function with the existing version. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
alexmerfi Posted June 29, 2018 Share Posted June 29, 2018 (edited) the handle do not return from the new tab, because this tab does not have time to create Fixed _WD_NewTab Func _WD_NewTab($sSession, $lSwitch = True) Local Const $sFuncName = "_WD_NewTab" Local $sTabHandle = '' Local $TimerNewTab = 0 _WD_ExecuteScript($sSession, 'window.open()', '{}') $TimerNewTab = TimerInit() While 1 If TimerDiff($TimerNewTab) > 5000 Then Return SetError($_WD_ERROR_Success, 0, $sTabHandle) If @error = $_WD_ERROR_Success Then Local $aHandles = _WD_Window($sSession, 'handles', '') $sTabHandle = $aHandles[UBound($aHandles) - 1] If $lSwitch Then _WD_Window($sSession, 'Switch', '{"handle":"' & $sTabHandle & '"}') EndIf ExitLoop EndIf Sleep(10) WEnd Return SetError($_WD_ERROR_Success, 0, $sTabHandle) EndFunc ;==>_WD_NewTab Now, if the tab is not created within 5 seconds, it returns an SetError Edited June 29, 2018 by alexmerfi Link to comment Share on other sites More sharing options...
alexmerfi Posted June 29, 2018 Share Posted June 29, 2018 (edited) deleted message Edited June 29, 2018 by alexmerfi Link to comment Share on other sites More sharing options...
Danp2 Posted June 29, 2018 Author Share Posted June 29, 2018 7 hours ago, alexmerfi said: the handle do not return from the new tab, because this tab does not have time to create Thanks for the feedback. Can you provide further details so that I can replicate the issue? Which browser, etc. Also, I can see a few issues with this revised implementation, such as -- Possible misplaced If @error check. Wrong return value when timeout occurs How do you determine that the new tab exists? Finally, I would suggest making the timer "max" value an optional parameter. P.S. Perhaps an even simpler implementation would be to replace the timer loop with a single Sleep command using the same optional variable to allow the calling routine to determine the desired delay length. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
alexmerfi Posted July 1, 2018 Share Posted July 1, 2018 On 29.06.2018 at 5:06 PM, Danp2 said: Thanks for the feedback. Can you provide further details so that I can replicate the issue? Which browser, etc. Firefox 61.0 64 bit, Hyperv Windows 10 x32 Autoit 3.3.14.2 #include "wd_core.au3" #include "wd_helper.au3" Global $sSession Global $sDesiredCapabilities $_WD_DEBUG = False SetupGecko() _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) $HandleTab = _WD_NewTab($sSession, True) MsgBox(0, "", $HandleTab) _WD_DeleteSession($sSession) _WD_Shutdown() Exit 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 ;==>SetupGecko Link to comment Share on other sites More sharing options...
alexmerfi Posted July 1, 2018 Share Posted July 1, 2018 On 29.06.2018 at 5:06 PM, Danp2 said: How do you determine that the new tab exists? If $HandleTab<>'' then MsgBox(0,"","Table IS EXIST, because it return value of handle") _WD_Window($sSession, 'Switch', '{"handle":"' & $HandleTab & '"}') EndIf Link to comment Share on other sites More sharing options...
alexmerfi Posted July 1, 2018 Share Posted July 1, 2018 On 29.06.2018 at 5:06 PM, Danp2 said: Wrong return value when timeout occurs Why Wrong? if i change timeout 5000 to 0 If TimerDiff($TimerNewTab) > 0 Then Return SetError($_WD_ERROR_Success, 0, $sTabHandle) i return $HandleTab='' (nothing) Link to comment Share on other sites More sharing options...
alexmerfi Posted July 1, 2018 Share Posted July 1, 2018 On 29.06.2018 at 5:06 PM, Danp2 said: Possible misplaced If @error check. Yes, you're right, I have not yet found how to fix this inside this function. Perhaps, if the _WD_ExecuteScript will store errors in the global variable, and I will check it through While 1 if $GlobalVariableOfErrorExecuteScript='okay' then exitloop wend Link to comment Share on other sites More sharing options...
alexmerfi Posted July 1, 2018 Share Posted July 1, 2018 On 29.06.2018 at 5:06 PM, Danp2 said: P.S. Perhaps an even simpler implementation would be to replace the timer loop with a single Sleep command using the same optional variable to allow the calling routine to determine the desired delay length. Yes, this is a simple implementation. But, for example, if you have a heavily loaded virtual machine and the fiefox tab will be created for a very long time, it will not always work sleep. Of course SLEEP can be done for 5 minutes but in some tasks some people can lose a lot of money. Link to comment Share on other sites More sharing options...
Danp2 Posted July 1, 2018 Author Share Posted July 1, 2018 1 hour ago, alexmerfi said: Firefox 61.0 64 bit, Hyperv Windows 10 x32 Autoit 3.3.14.2 Does it fail for you every time in this environment? If so, please change $_WD_DEBUG = True and post the contents of the Scite output window after running your code. Also, is there a reason you aren't running the latest version of Autoit? 1 hour ago, alexmerfi said: If $HandleTab<>'' then MsgBox(0,"","Table IS EXIST, because it return value of handle") _WD_Window($sSession, 'Switch', '{"handle":"' & $HandleTab & '"}') EndIf But the current implementation should return the handle of the last tab (even if the newest one hasn't appeared as you previously indicated). So $HandleTab would only be blank if there was an error from _WD_ExecuteScript. 1 hour ago, alexmerfi said: Why Wrong? if i change timeout 5000 to 0 If TimerDiff($TimerNewTab) > 0 Then Return SetError($_WD_ERROR_Success, 0, $sTabHandle) i return $HandleTab='' (nothing) Actually, I meant the error code, not the return value. I would use $_WD_ERROR_Timeout here instead of $_WD_ERROR_Success 59 minutes ago, alexmerfi said: Yes, you're right, I have not yet found how to fix this inside this function. Perhaps, if the _WD_ExecuteScript will store errors in the global variable, and I will check it through Shouldn't be necessary to use a global here. Look at other instance where the value of @error is saved to $iErr. Latest Webdriver UDF Release Webdriver Wiki FAQs 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