Can not save selected option in javascript form

8 posts, 0 answers
  1. Asta
    Asta avatar
    29 posts
    Member since:
    Nov 2011

    Posted 20 Jun 2013 Link to this post

    hi, i have tried everything that i find in forums and so on and i have stuck. I can not save selected option from select (drop down). Developers are using angularJs framework (Javascript-based). Events, SelectByText, Desktop.Mouse.Click and so on didn't helped....

    Currently my code looks like this:

    Browser.RefreshDomTree();
    var select = Browser.Find.ByAttributes<HtmlSelect>(attributes);
    select.MouseClick();
    Thread.Sleep(Extensions.SmallTimeOut);
    Browser.RefreshDomTree();
    select = Browser.Find.ByAttributes<HtmlSelect>(attributes);
    var option = select.Options.First(itm => itm.Text.Equals(value));
    option.Click();

  2. Asta
    Asta avatar
    29 posts
    Member since:
    Nov 2011

    Posted 20 Jun 2013 Link to this post

    Example this drop down example
  3. Faris
    Faris avatar
    4 posts
    Member since:
    Jun 2008

    Posted 20 Jun 2013 Link to this post

    Hi Asha - You might need to invoke the OnChangeEvent on the dropdown.

    DropDown.SelectByValue("foo",true);

    Here is a code snippet tested against the code you pointed us to:
    [TestMethod]
            public void Support_Issue()
            {
     
                Manager.LaunchNewBrowser(BrowserType.InternetExplorer);
                ActiveBrowser.NavigateTo("http://jsfiddle.net/2JWb2/5/");
     
                Browser jFiddleResultsFrame = ActiveBrowser.WaitForFrame(new FrameInfo
                {
                    Name = "result"
                });
     
                List<HtmlSelect> dropdown = jFiddleResultsFrame.Find.AllControls<HtmlSelect>().ToList();
     
                foreach (HtmlSelect s in dropdown)
                {
                    Console.WriteLine(string.Format("Before Selection: {0}", s.SelectedIndex));
                    s.SelectByValue("2", true);
                    s.Refresh(); // Ensure the DOM is update for this particular control.
                    Console.WriteLine(string.Format("After Selection: {0}", s.SelectedIndex));
                }
            }

    This sample simply returns "All" the dropdowns on the page you pointed us to and selected a specific value and then outputs it. I hope that helps :)
  4. Boyan Boev
    Admin
    Boyan Boev avatar
    1039 posts

    Posted 24 Jun 2013 Link to this post

    Hello,

    @Faris, thank you for your input.

    @Asta, are you still experiencing the issue? 

    Should you have any additional questions please do not hesitate to ask us.
     

    Regards,
    Boyan Boev
    Telerik
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  5. Asta
    Asta avatar
    29 posts
    Member since:
    Nov 2011

    Posted 25 Jun 2013 Link to this post

    Yes, it didn't help.
  6. Boyan Boev
    Admin
    Boyan Boev avatar
    1039 posts

    Posted 26 Jun 2013 Link to this post

    Hello Asta,

    As you can see in this video the code works correctly.

    Please elaborate a bit more on your scenario. What exactly don't work?

    1. Please send us the execution log.

    2. Can you please record a Jing video demonstrating the issue? 

    Hope to hear from you soon.

    Regards,
    Boyan Boev
    Telerik
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  7. Asta
    Asta avatar
    29 posts
    Member since:
    Nov 2011

    Posted 26 Aug 2013 Link to this post

    i found solution myself....
    Browser.RefreshDomTree();
    var select = Browser.Find.ByAttributes<HtmlSelect>(attributes);
    select.SelectByText(value, true);
    jQueryControl jQueryControl = select.AsjQueryControl();
    jQueryControl.InvokejQueryEvent(jQueryControl.jQueryControlEvents.change);

  8. Boyan Boev
    Admin
    Boyan Boev avatar
    1039 posts

    Posted 29 Aug 2013 Link to this post

    Hi Asta,

    We are glad to hear that.

    If you need additional assistance do not hesitate to contact us.

    Regards,
    Boyan Boev
    Telerik
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
Back to Top