This is a migrated thread and some comments may be shown as answers.
Can not save selected option in javascript form
7 Answers 26 Views
This is a migrated thread and some comments may be shown as answers.
Asta
Top achievements
Rank 1
Asta asked on 20 Jun 2013, 01:37 PM
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();

7 Answers, 1 is accepted

Sort by
0
Asta
Top achievements
Rank 1
answered on 20 Jun 2013, 01:40 PM
Example this drop down example
0
Faris
Top achievements
Rank 1
answered on 20 Jun 2013, 05:02 PM
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 :)
0
Boyan Boev
Telerik team
answered on 24 Jun 2013, 08:29 AM
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
0
Asta
Top achievements
Rank 1
answered on 25 Jun 2013, 08:31 AM
Yes, it didn't help.
0
Boyan Boev
Telerik team
answered on 26 Jun 2013, 01:35 PM
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
0
Asta
Top achievements
Rank 1
answered on 26 Aug 2013, 08:19 AM
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);

0
Boyan Boev
Telerik team
answered on 29 Aug 2013, 08:59 AM
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
Asked by
Asta
Top achievements
Rank 1
Answers by
Asta
Top achievements
Rank 1
Faris
Top achievements
Rank 1
Boyan Boev
Telerik team
Share this question
or