MilenP Posted May 9, 2019 Share Posted May 9, 2019 (edited) @Danp2, The associated source code to this is: _WD_jQuerify($sSession) Local $script = 'jQuery("#manager_manager_id").append(<option value=' & $parentAccountID & ' selected>' & $parentAccount & '</option>' _WD_ExecuteScript($sSession, $script) Local $script = 'jQuery("#manager_manager_id").trigger("change")' _WD_ExecuteScript($sSession, $script) Everything else is working, I am also using the _WD_ExecuteScript for another purpose, like the below, and it is working correctly: $script = "return document.getElementById('company_list').getElementsByClassName('text_cell').length;" $countOfElementsInTableRaw = _WD_ExecuteScript($sSession, $script) Also maybe I should mention, that the window I am operating with is a PopUp window on the main one. Another commands on it are working, but this one not. Please advise if I have to use something like _WD_Attach when there are some changes on the page. Thanks, Milen Edited May 9, 2019 by MilenP Link to comment Share on other sites More sharing options...
Danp2 Posted May 9, 2019 Author Share Posted May 9, 2019 I believe the issue is the use of double quotes. _WD_ExecuteScript is coded to surround the script with double quotes, so I think this confuses the webdriver. Can you try it like this? _WD_jQuerify($sSession) $script = "jQuery('#manager_manager_id').append(<option value=" & $parentAccountID & " selected>" & $parentAccount & "</option>" _WD_ExecuteScript($sSession, $script) $script = "jQuery('#manager_manager_id').trigger('change')" _WD_ExecuteScript($sSession, $script) MilenP 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
MilenP Posted May 9, 2019 Share Posted May 9, 2019 @Danp2, I did the changes, but the same happens. You can see the logs below expandcollapse popup} [1557413304.406][INFO]: Waiting for pending navigations... [1557413304.407][INFO]: Done waiting for pending navigations. Status: ok [1557413304.410][INFO]: Waiting for pending navigations... [1557413304.411][INFO]: Done waiting for pending navigations. Status: ok [1557413304.411][INFO]: [bb47c585ecd04b2a665a95077fccf034] RESPONSE GetElementProperty "ge5TmgZT" [1557413304.415][INFO]: [bb47c585ecd04b2a665a95077fccf034] COMMAND ExecuteAsyncScript { "args": [ [ ] ], "script": "(function(jqueryUrl, callback) { if (typeof jqueryUrl != 'string') { jqueryUrl = 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'; } if (typeof jQuery == 'undefine..." } [1557413304.415][INFO]: Waiting for pending navigations... [1557413304.416][INFO]: Done waiting for pending navigations. Status: ok [1557413304.421][INFO]: Waiting for pending navigations... [1557413304.422][INFO]: Done waiting for pending navigations. Status: ok [1557413304.422][INFO]: [bb47c585ecd04b2a665a95077fccf034] RESPONSE ExecuteAsyncScript null [1557413304.681][INFO]: [bb47c585ecd04b2a665a95077fccf034] COMMAND ExecuteScript { "args": [ [ ] ], "script": "jQuery" } [1557413304.681][INFO]: Waiting for pending navigations... [1557413304.682][INFO]: Done waiting for pending navigations. Status: ok [1557413304.684][INFO]: Waiting for pending navigations... [1557413304.685][INFO]: Done waiting for pending navigations. Status: ok [1557413304.685][INFO]: [bb47c585ecd04b2a665a95077fccf034] RESPONSE ExecuteScript [1557413305.689][INFO]: [bb47c585ecd04b2a665a95077fccf034] COMMAND ExecuteAsyncScript { "args": [ [ ] ], "script": "(function(jqueryUrl, callback) { if (typeof jqueryUrl != 'string') { jqueryUrl = 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'; } if (typeof jQuery == 'undefine..." } [1557413305.689][INFO]: Waiting for pending navigations... [1557413305.690][INFO]: Done waiting for pending navigations. Status: ok [1557413305.694][INFO]: Waiting for pending navigations... [1557413305.694][INFO]: Done waiting for pending navigations. Status: ok [1557413305.694][INFO]: [bb47c585ecd04b2a665a95077fccf034] RESPONSE ExecuteAsyncScript null [1557413305.951][INFO]: [bb47c585ecd04b2a665a95077fccf034] COMMAND ExecuteScript { "args": [ [ ] ], "script": "jQuery" } [1557413305.951][INFO]: Waiting for pending navigations... [1557413305.952][INFO]: Done waiting for pending navigations. Status: ok [1557413305.953][INFO]: Waiting for pending navigations... [1557413305.954][INFO]: Done waiting for pending navigations. Status: ok [1557413305.954][INFO]: [bb47c585ecd04b2a665a95077fccf034] RESPONSE ExecuteScript [1557413305.957][INFO]: [bb47c585ecd04b2a665a95077fccf034] COMMAND ExecuteScript { "args": [ [ ] ], "script": "jQuery('#manager_manager_id').append(\u003Coption value=4001 selected>Production\u003C/option>" } [1557413305.957][INFO]: Waiting for pending navigations... [1557413305.957][INFO]: Done waiting for pending navigations. Status: ok [1557413305.960][INFO]: Waiting for pending navigations... [1557413305.960][INFO]: Done waiting for pending navigations. Status: ok [1557413305.960][INFO]: [bb47c585ecd04b2a665a95077fccf034] RESPONSE ExecuteScript ERROR unknown error: Runtime.evaluate threw exception: SyntaxError: Unexpected token < (Session info: chrome=74.0.3729.131) [1557413305.963][INFO]: [bb47c585ecd04b2a665a95077fccf034] COMMAND ExecuteScript { "args": [ [ ] ], "script": "jQuery('#manager_manager_id').trigger('change')" } [1557413305.963][INFO]: Waiting for pending navigations... [1557413305.963][INFO]: Done waiting for pending navigations. Status: ok [1557413305.968][INFO]: Waiting for pending navigations... [1557413305.970][INFO]: Done waiting for pending navigations. Status: ok [1557413305.970][INFO]: [bb47c585ecd04b2a665a95077fccf034] RESPONSE ExecuteScript [1557413307.976][INFO]: [bb47c585ecd04b2a665a95077fccf034] COMMAND FindElement { "using": "xpath", "value": "//input[@id='newcompany_submit_button']" __WD_Post: URL=HTTP://127.0.0.1:9515/session/bb47c585ecd04b2a665a95077fccf034/execute/sync; $sData={"script":"jQuery", "args":[[]]} __WD_Post: StatusCode=200; ResponseText={"value":null} _WD_ExecuteScript: {"value":null} __WD_Post: URL=HTTP://127.0.0.1:9515/session/bb47c585ecd04b2a665a95077fccf034/execute/sync; $sData={"script":"jQuery('#manager_manager_id').append(<option value=4001 selected>Production</option>", "args":[[]]} __WD_Post: StatusCode=500; ResponseText={"value":{"error":"unknown error","message":"Runtime.evaluate threw exception: SyntaxError: Unexpected token \u003C\n (Session info: chrome=74.0.3729.131)","stacktrace":"Backtrace:\n\tOrdinal0 [0x00ECDB63+1432419]\n\tOrdinal0 [0x00E48D81+888193]\n\tOrdinal0 [0x00DEB9D1+506321]\n\tOrdinal0 [0x00DF0907+526599]\n\tOrdinal0 [0x00DED34D+512845]\n\tOrdinal0 [0x00DED184+512388]\n\tOrdinal0 [0x00DED562+513378]\n\tOrdinal0 [0x00DA7366+226150]\n\tOrdinal0 [0x00D9EA0D+190989]\n\tOrdinal0 [0x00DA6D94+224660]\n\tOrdinal0 [0x00D9E8AB+190635]\n\tOrdinal0 [0x00D85F16+89878]\n\tOrdinal0 [0x00D8757A+95610]\n\tOrdinal0 [0x00D87474+95348]\n\tGetHandleVerifier [0x0102DE7C+1274156]\n\tGetHandleVerifier [0x00F7B6D9+543113]\n\tGetHandleVerifier [0x00F7B4E0+542608]\n\tOrdinal0 [0x00EDB508+1488136]\n\tGetHandleVerifier [0x00F7BC86+544566]\n\tOrdinal0 [0x00E5EEC5+978629]\n\tOrdinal0 [0x00E6B35B+1028955]\n\tOrdinal0 [0x00E6B49F+1029279]\n\tOrdinal0 [0x00E6A445+1025093]\n\tBaseThreadInitThunk [0x764C8494+36]\n\tRtlAreBitsSet [0x77B441C8+136]\n\tRtlAreBitsSet [0x77B44198+88]\n"}} _WD_ExecuteScript: {"value":{"error":"unknown error","message":"Runtime.evaluate threw exception: SyntaxError: Unexpected token \u003C\n (Session info: chrome=74.0.3729.131)","stacktrace":"Backtrace:\n\tOrdinal0 [0x00ECDB63+1432419]\n\tOrdinal0 [0x00E48D81+888193]\n\tOrdinal0 [0x00DEB9D1+506321]\n\tOrdinal0 [0x00DF0907+526599]\n\tOrdinal0 [0x00DED34D+512845]\n\tOrdinal0 [0x00DED184+512388]\n\tOrdinal0 [0x00DED562+513378]\n\tOrdinal0 [0x00DA7366+226150]\n\tOrdinal0 [0x00D9EA0D+190989]\n\tOrdinal0 [0x00DA6D94+224660]\n\tOrdinal0 [0x00D9E8AB+190635]\n\tOrdinal0 [0x00D85F16+89878]\n\tOrdinal0 [0x00D8757A+95610]\n\tOrdinal0 [0x00D87474+95348]\n\tGetHandleVerifier [0x0102DE7C+1274156]\n\tGetHandleVerifier [0x00F7B6D9+543113]\n\tGetHandleVerifier [0x00F7B4E0+542608]\n\tOrdinal0 [0x00EDB508+1488136]\n\tGetHandleVerifier [0x00F7BC86+544566]\n\tOrdinal0 [0x00E5EEC5+978629]\n\tOrdinal0 [0x00E6B35B+1028955]\n\tOrdinal0 [0x00E6B49F+1029279]\n\tOrdinal0 [0x00E6A445+1025093]\n\tBaseThreadInitThunk [0x764C8494+36]\n\tRtlAreBitsSet [0x77B441C8+136]\n\tRtlAreBitsSet [0x77B44198+88]\n"}} __WD_Post: URL=HTTP://127.0.0.1:9515/session/bb47c585ecd04b2a665a95077fccf034/execute/sync; $sData={"script":"jQuery('#manager_manager_id').trigger('change')", "args":[[]]} Link to comment Share on other sites More sharing options...
Danp2 Posted May 9, 2019 Author Share Posted May 9, 2019 10 minutes ago, Danp2 said: $script = "jQuery('#manager_manager_id').append(<option value=" & $parentAccountID & " selected>" & $parentAccount & "</option>" In hind sight, I believe you are missing some quotes (not sure if I caused this. Also, I think a missing close parentheses. Try -- $script = "jQuery('#manager_manager_id').append('<option value=" & $parentAccountID & " selected>'" & $parentAccount & "</option>)" You can also issue a ConsoleWrite to output this string to the console so that you can make sure it looks correct. MilenP 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
MilenP Posted May 9, 2019 Share Posted May 9, 2019 (edited) @DanP2, Now the error is different, but the result is always this: The page is broken and the Select2 Dropdowns as well. The error now is: "script": "jQuery('#manager_manager_id').append('\u003Coption value=4001 selected>'Production\u003C/option>)" } [1557414289.515][INFO]: Waiting for pending navigations... [1557414289.515][INFO]: Done waiting for pending navigations. Status: ok [1557414289.518][INFO]: Waiting for pending navigations... [1557414289.519][INFO]: Done waiting for pending navigations. Status: ok [1557414289.519][INFO]: [9d41960f4ed07eb17d092c88ed117376] RESPONSE ExecuteScript ERROR unknown error: Runtime.evaluate threw exception: SyntaxError: missing ) after argument list Do you think that I have to escape the "<" symbol, as it is converted in "\u003" ? Thanks, Milen Edited May 9, 2019 by MilenP Link to comment Share on other sites More sharing options...
Danp2 Posted May 9, 2019 Author Share Posted May 9, 2019 3 minutes ago, MilenP said: Do you think that I have to escape the "<" symbol, as it is converted in "\u003" ? Could be... but I still think there's an issue with your quotes. The single quote near "selected" should be after the "</option>". Also, I believe you need quotes around the string following "value=". I'm thinking that I need to modify _WD_ExecuteScript to escape any quotes within the $sScript variable. MilenP 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
MilenP Posted May 9, 2019 Share Posted May 9, 2019 @Danp2, It was the quotes, yes... Thank you, fixed: $script = "jQuery('#manager_manager_id').append('<option value=" & $parentAccountID & " selected>" & $parentAccount & "</option>')" $script = "jQuery('#manager_manager_id').append('<option value=" & $parentAccountID & " selected>" & $parentAccount & "</option>')" Now it seems that the issue is with the data passed to the Ajax, append('<option value=4001 This option, 4001, exist in it, but when entered with the jQuery, it is broken. If you have any idea here, it is welcome. I will investigate it tomorrow and hopefully will find the issue Thank you very much Dan. Cheers, Milen Link to comment Share on other sites More sharing options...
Danp2 Posted May 9, 2019 Author Share Posted May 9, 2019 8 minutes ago, MilenP said: Now it seems that the issue is with the data passed to the Ajax, append('<option value=4001 This option, 4001, exist in it, but when entered with the jQuery, it is broken. Not sure I understand. Best option at this point is to find a publicly accessible website that we can use for testing purposed. Then adjust your code to use that and post it here. Otherwise, use ConsoleWrite to output the complete $script string and post it here for examination. MilenP 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
MilenP Posted May 10, 2019 Share Posted May 10, 2019 @Danp2, I found the issue... It was that I am injecting the Jquery with _WD_jQuerify($sSession), I am breaking the page, as it already has Jquery. To fix the issue, I simply don't inject the JQuery again and just use the _WD_ExecuteScript and it is all good. Thank you for your help. Best, Milen Link to comment Share on other sites More sharing options...
Danp2 Posted May 10, 2019 Author Share Posted May 10, 2019 4 hours ago, MilenP said: found the issue... It was that I am injecting the Jquery with _WD_jQuerify($sSession), I am breaking the page, as it already has Jquery. Hmmm... that's interesting because I don't believe this should happen. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Danp2 Posted May 13, 2019 Author Share Posted May 13, 2019 New update just released on GH. Please let me know if you encounter any issues. MilenP 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
esentio Posted June 19, 2019 Share Posted June 19, 2019 @Danp2 function _WD_ElementAction requires to escape characters \ and " . Link to comment Share on other sites More sharing options...
Danp2 Posted June 19, 2019 Author Share Posted June 19, 2019 Hi @esentio, I'm guessing that you're talking about when $sCommand = 'value'. Please confirm. Thanks, Dan Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
esentio Posted June 19, 2019 Share Posted June 19, 2019 Hi @Danp2, yes this is for $sCommand = 'value' when \ is not start of unicode character definition but actual character to set. Regards Link to comment Share on other sites More sharing options...
Danp2 Posted June 19, 2019 Author Share Posted June 19, 2019 @esentio I can add a call to __WD_EscapeString in this section of code. However, that would only escape the double quotes unless we also modify the value of $_WD_ESCAPE_CHARS. This function (__WD_EscapeString) is already being called by _WD_FindElement & _WD_ExecuteScript, and changes to $_WD_ESCAPE_CHARS would affect these functions as well. Would appreciate your thoughts, especially when it comes to the backslash character and avoiding creating issues with unicode characters. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Laks Posted June 19, 2019 Share Posted June 19, 2019 Hello Dan, I am getting the error "on port 9515 only local connections are allowed " when trying to launch Chromedriver.exe. So I have used "Chrome_Proxy". But then session is not created. My Chrome version is 75.0.3770.100 and I downloaded the same version chrome driver. Please help Link to comment Share on other sites More sharing options...
esentio Posted June 19, 2019 Share Posted June 19, 2019 Hi @Danp2, thank you for quick replay. Maybe it is good idea to add additional optional escapeValue flag (default false) to _WD_ElementAction function. In this case flag is set to true values can be escaped similar to __WD_EscapeString - StringRegExpReplace($sData, '(["\\])', "\\$1"). In case of mixed unicode string user will have to implement correct formatting before function is invoked. Regards Piotr Link to comment Share on other sites More sharing options...
Danp2 Posted June 19, 2019 Author Share Posted June 19, 2019 2 hours ago, Laks said: am getting the error "on port 9515 only local connections are allowed " when trying to launch Chromedriver.exe. I believe this is normal (msg is informational only). Did you experience any other issues when using Chromedriver? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Danp2 Posted June 19, 2019 Author Share Posted June 19, 2019 @esentio don't think I want to add more parameters. Other option is to add note that string should be escaped prior to passing to function or that value of $_WD_ESCAPE_CHARS can be adjusted as desired Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
MilenP Posted June 21, 2019 Share Posted June 21, 2019 (edited) @Danp2, I have the followig question. When I try to use the GeckoDriver and open website, for which I have to select a Certificate for, it is not working. There is no certificates in the session that is started by the WebDriver. From what I can see, it is not selecting the default profile, under which I have the certificates imported for the Firefox. Can you please advise me, what I should do using this "marionette" in order to start the default profile with the certificates imported? I use the following desiredCapabilities: $sDesiredCapabilities = '{"desiredCapabilities":{"javascriptEnabled":true,"nativeEvents":true,"acceptInsecureCerts":true}}' Thank you in advance, --- Milen Edited June 21, 2019 by MilenP 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