Answered by:
Coded UI: problem when running javascript on file dialog

Question
-
I am trying to write automation test using coded UI for a web page on Edge browser in which clicking on import button (on a popup) opens a file dialog to select an excel file from local computer. Unfortunately I cannot find and click the import button so i use javascript to do that. After clicking on the import button by javascript, file dialog to select an excel file from local computer displays but it does not perform the next steps. I debugged and found that after file dialog displays, the code stuck at ExecuteScript method. I waited for a long time then the code got fail
Below is my code:
string script = "document.getElementsByClassName('ms-dlgFrame')[0].contentWindow.document.getElementById('ctl00_PlaceHolderMain_UploadDocumentSection_ctl05_InputFile').click();";
Browser.ExecuteScript(script); // This code stuck here after file dialog displaysKeyboard.SendKeys(documentPath);
Thanks
- Edited by James90VN Thursday, October 25, 2018 3:25 AM
Thursday, October 25, 2018 3:24 AM
Answers
-
@James,
Thanks for your friendly response.
It would be related to the Edge with the coded UI cross browser extension, for example, like above case we discussed, it really doesn't support certain functions like WaitForControlExist or others, it really impacts the files' uploaded during you playback the coded UI test.
You could also report this issue under the Selenium components for Coded UI Cross Browser Testing download site directly. Thanks for your feedback:)
If it is urgent for you to test your web app, using other browser instead of the Edge would be better now.
Sincerely,
Jack
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.- Proposed as answer by Jack Zhai-MSFTMicrosoft contingent staff Friday, October 26, 2018 10:00 AM
- Marked as answer by James90VN Monday, October 29, 2018 9:48 AM
- Unmarked as answer by James90VN Monday, October 29, 2018 9:49 AM
- Marked as answer by James90VN Wednesday, October 31, 2018 3:25 AM
Friday, October 26, 2018 9:44 AM
All replies
-
Hi James,
Glad to see you again.
Firstly, since you also get another error using the Edge, so we have to make sure that it was not the Edge issue firstly, so if possible, I suggest you run your coded UI test using the IE, and check that whether it has the same issue.
In addition, as you said that the steps were used to upload files, please check that whether the real issue is related to the fire path, so you could edit the code manually like this case:
https://stackoverflow.com/questions/7968318/coded-ui-testing-in-ie-how-to-upload-a-file
Best Regards,
Jack
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.Friday, October 26, 2018 1:42 AM -
Thank you, Jack!
It is not related to file path, because in IE, we can find the control and it works like a charm. However, when play back in Edge, the control cannot be found. We tried like a milion ways but no lucks. Then we use the javascript for this case but it turns out another issue.
Thanks
Friday, October 26, 2018 4:12 AM -
@James,
Thanks for your friendly response.
It would be related to the Edge with the coded UI cross browser extension, for example, like above case we discussed, it really doesn't support certain functions like WaitForControlExist or others, it really impacts the files' uploaded during you playback the coded UI test.
You could also report this issue under the Selenium components for Coded UI Cross Browser Testing download site directly. Thanks for your feedback:)
If it is urgent for you to test your web app, using other browser instead of the Edge would be better now.
Sincerely,
Jack
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.- Proposed as answer by Jack Zhai-MSFTMicrosoft contingent staff Friday, October 26, 2018 10:00 AM
- Marked as answer by James90VN Monday, October 29, 2018 9:48 AM
- Unmarked as answer by James90VN Monday, October 29, 2018 9:49 AM
- Marked as answer by James90VN Wednesday, October 31, 2018 3:25 AM
Friday, October 26, 2018 9:44 AM -
Thank you, Jack!Friday, October 26, 2018 10:34 AM
-
You are welcome:)
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.Monday, October 29, 2018 1:32 AM -
Thanks for your vote, James. It seems that you mark and unmark the reply, but I agree with you, it would be a really feedback. Using other browser would be the possible workaround now. You could also add your feedback to that extension tool directly.
If you meet any test issue, feel free to post it to this forum:)
Have a nice day,
Jack
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.Tuesday, October 30, 2018 1:47 AM -
Hi Jack,
It is not really a real answer for my issues. But it is maybe a temporary answer for now. So I marked it as an answser again.
Thank you for your help!
Regards,
James
- Edited by James90VN Wednesday, October 31, 2018 3:25 AM
Wednesday, October 31, 2018 3:25 AM