This is a migrated thread and some comments may be shown as answers.

HTMLControls Click only clicks the first button

2 Answers 86 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Mexi
Top achievements
Rank 1
Mexi asked on 07 Jan 2019, 09:08 PM

Hi there,

I'm having problem clicking a button. This website is using Kendo UI so I was wondering if that makes it different for testing.

 

After I select a file to upload, there is a remove button displaying right next to the file.(Please see removebutton in attachment for more details.) I want to click the submit button after uploading a file but I can't. (Please see buttons to see both buttons) It always clicks the remove button unless I don't select a file, which means only when there's no remove button.  

 

Here is my code and it should select a file from my computer and click the SubmitButton to submit this file. 

            HtmlButton submitButton = manager.ActiveBrowser.Find.ById<HtmlButton>("SubmitButton");
         
            HtmlInputFile selectFile = manager.ActiveBrowser.Find.ByAttributes<HtmlInputFile>("type=file");
           
            FileUploadDialog uploadDialog = new FileUploadDialog(manager.ActiveBrowser, @"myfilepath", 
                DialogButton.OPEN,"Select files");
            manager.DialogMonitor.AddDialog(uploadDialog);

            selectFile.Click();

            manager.DialogMonitor.Start();

            uploadDialog.WaitUntilHandled(10000);
            
            submitButton.Click();

 

I've also included a screenshot of the html of the buttons. Please let me know if you need more information. Thank you! 

2 Answers, 1 is accepted

Sort by
0
Mexi
Top achievements
Rank 1
answered on 08 Jan 2019, 06:18 PM

Never mind. I moved the  HtmlButton submitButton = manager.ActiveBrowser.Find.ById<HtmlButton>("SubmitButton"); before clicking the button...and it works fine now. 

0
Elena
Telerik team
answered on 10 Jan 2019, 04:30 PM
Hello Mexi,

Thank you for contacting us. I am glad to know you managed to solve the issue on your end. 

However, while looking into your initial query I noticed there is something incorrect in the sequence of actions in the code. This is when the DialogMonitor is being started - this should be before the event which triggers the dialog in question. So the correct sequence should be: 

manager.DialogMonitor.Start();
 
selectFile.Click();

Please also find a sample of the Upload dialog handler in code which you can use for further reference. 

I hope there are no further issues, though if you need further assistance, please let us know. 

Regards,
Elena Tsvetkova
Progress Telerik
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
Tags
General Discussions
Asked by
Mexi
Top achievements
Rank 1
Answers by
Mexi
Top achievements
Rank 1
Elena
Telerik team
Share this question
or