HTMLControls Click only clicks the first button

3 posts, 0 answers
  1. Mexi
    Mexi avatar
    5 posts
    Member since:
    Jan 2019

    Posted 07 Jan Link to this post

    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. Mexi
    Mexi avatar
    5 posts
    Member since:
    Jan 2019

    Posted 08 Jan Link to this post

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

  3. Elena
    Admin
    Elena avatar
    1075 posts

    Posted 10 Jan Link to this post

    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
     
Back to Top