I want to select an option from a drop down menu that looks like this:<select id="CostType" onchange="javascript:setTimeout('__doPostBack(\'CostType\',\'\')', 0)" name="CostType">
<option value="">- Select One -</option><option value="Internal" selected="selected">Internal Cost</option><option value="External">Project Cost</option></select>I have tried using the following:SelectElement select = new SelectElement(CostType);select.SelectByText("Internal Cost");Using the above code, selenium will change the the correct option in the drop down menu. But it does not trigger Ajax that will get data from relevant units and then populate some other elements on the webpage. I also added wait after the select, but that does not solve the problem.This works fine if I do the process manually. I am using Selenium WebDriver C# on IE. I have tried Java on IE with the Select class and it worked fine. But it does not work when I'm using C#.Can anyone help me out with this? Thank you so much!--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/owtQTG7ygEYJ.
For more options, visit https://groups.google.com/groups/opt_out.
msiles, I tried it and it does not work.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/uNCS0ZwA_ksJ.
nothing happened.This line select.SelectByText("Internal Cost") will highlight the internal cost option and select it. But it does not trigger ajax like it would if you are doing it manually.I did a sendkeys(keys.enter) like you suggested. It did not do anything.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/0rOzBxgyTeIJ.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/_stwEwxzHEcJ.
<td id="TableCell1" class="formElement">
<span id="labelCostType">*Cost Type:</span>
</td>
<td id="TableCell2" class="formElement">
<select id="ddlCostType" onchange="javascript:setTimeout('__doPostBack(\'ddlCostType\',\'\')', 0)" name="ddlCostType">
<option value="">- Select One -</option><option value="Internal" selected="selected">Internal Cost</option><option value="External">Project Cost</option>
</select>
<span id="rfvDdlCostType" style="color:Red;display:none;">Required Field</span>
</td>
//I have tried this//
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/_stwEwxzHEcJ.
Under the covers, at the wire protocol level, the .NET bindings and the Java bindings should be using the exact same methods to communicate with the IEDriverServer.exe. An examination of the bindings' source code confirms this. Moreover, I've tested several similar scenarios with .NET and IE, and they've worked flawlessly. So if you want me to have a proverbial snowball's chance in hell of debugging the issue, I'll need a full, complete repro case.
Oh, and before you reply why supplying a repro case is impossible, head over to http://jimevansmusic.blogspot.com/2012/12/not-providing-html-page-is-bogus.html and give it a read. If your reasons for insisting a repro page is impossible are one of these, then it's not that you can't supply one, it's just that you aren't willing to.
--
You received this message because you are subscribed to a topic in the Google Groups "Selenium Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/selenium-users/nwWwPHU7Chs/unsubscribe?hl=en-US.
To unsubscribe from this group and all its topics, send an email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/T7QJ0Bb8JGwJ.
IWebDriver driver = new InternetExplorerDriver(IEurl);driver.Navigate().GoToUrl(url);IWebElement ele = driver.FindElement(By.Id("ctl02_eigdAddItemGroupReport_ddlCostType"));SelectElement select = new SelectElement(ele);select.SelectByValue("Internal");
<select name="ctl02$eigdAddItemGroupReport$ddlCostType" onchange="javascript:setTimeout('__doPostBack(\'ctl02$eigdAddItemGroupReport$ddlCostType\',\'\')', 0)" id="ctl02_eigdAddItemGroupReport_ddlCostType">
to<select id="ctl02_eigdAddItemGroupReport_ddlCostType" name="ctl02$eigdAddItemGroupReport$ddlCostType"onchange="alert('Hello')">
The ScriptResources.axd file mentioned about onchange. The ScriptResource3.axd mentioned about postback. I assume that's why I'm seeing the above behavior. But I don't know enough about JavaScript to figure out a solution. I would really appreciate any help I can get. If there is other relevant information I didn't provide, please let me know. I will do my best.only ScriptResources.axd will cause the problem. ScriptResource3.axd doesn't.
--
You received this message because you are subscribed to a topic in the Google Groups "Selenium Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/selenium-users/nwWwPHU7Chs/unsubscribe?hl=en-US.
To unsubscribe from this group and all its topics, send an email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/gizIMx9JpXUJ.
Hi Jim.Like you suggested, I narrowed down the problem and reproduced it on my local machine. I have attached the full page and the JavaScript files that are causing the problems.Without the two JavaScript files, my selenium test will work fine. It will choose the option in the dropdown and trigger the onchange event. You will see IE tries to go to a new page and shows "IE cannot display the web page" (since the page is not included). This is the expected behavior.However, if you include the two JavaScript files attached, selenium will choose the option in the dropdown and sits on that page; onchange event is not triggered in this case. In either case (with or without the Javascript files), choosing the dropdown manually by mouse click will trigger the onchange event.There are several other JavaScript files mentioned in the HTML, but only the JavaScript files attached will cause selenium to not fire the onchange event.Below is the selenium code I used to test it.IWebDriver driver = new InternetExplorerDriver(IEurl);driver.Navigate().GoToUrl(url);IWebElement ele = driver.FindElement(By.Id("ctl02_eigdAddItemGroupReport_ddlCostType"));SelectElement select = new SelectElement(ele);select.SelectByValue("Internal");When I change the following line in FullPage.html:<select name="ctl02$eigdAddItemGroupReport$ddlCostType" onchange="javascript:setTimeout('__doPostBack(\'ctl02$eigdAddItemGroupReport$ddlCostType\',\'\')', 0)" id="ctl02_eigdAddItemGroupReport_ddlCostType">to<select id="ctl02_eigdAddItemGroupReport_ddlCostType" name="ctl02$eigdAddItemGroupReport$ddlCostType"onchange="alert('Hello')">The ScriptResources.axd file mentioned about onchange. The ScriptResource3.axd mentioned about postback. I assume that's why I'm seeing the above behavior. But I don't know enough about JavaScript to figure out a solution. I would really appreciate any help I can get. If there is other relevant information I didn't provide, please let me know. I will do my best.only ScriptResources.axd will cause the problem. ScriptResource3.axd doesn't.
Thanks!Qian
On Mon, Apr 8, 2013 at 4:28 PM, Jim Evans wrote:
You posted *something*, I'll grant you that. Tell me this: Are you able to copy the page that you posted into a locally running web server, browser to it, and reproduce your issue? I'd venture to say you can't. There's lots of "__doPostBack" calls in the source of the page you've provided. I don't know how to load this page into a web server, and verify that the AJAX call is or isn't being called, because the back-end processing of the system you're linked to isn't available. Nor do I have the JavaScript source files referenced in the source code of the page you posted. Even attempting to use IIS to host the page yields a ton of errors just browsing to the page in IE.
At this point, you have two choices. First, you can make the *actual* page available that reproduces the problem. Note that if this is an internal application (which it most likely is, given the tone of the questions you've been asking so far), you'll need to fix the system so that an external browser can access the page. Second, you can take the page you posted, and start stripping out extraneous items, until you're left with a page that can be dropped into a stock web server, that still reproduces the issue.
On Monday, April 8, 2013 1:01:38 PM UTC-7, Qian Xie wrote:Can anyone help me with this issue please? I have posted the full page in a previous post. I've searched everywhere but couldn't find a solution that works....--
On Monday, April 8, 2013 9:58:54 AM UTC-4, Qian Xie wrote:Hi Madan,I tried using SelectByValue as you suggested. It selects the correct option just like SelectByText, but still does not trigger the onchange event.Any other suggestions?Thanks!Qian
On Saturday, April 6, 2013 12:25:15 AM UTC-4, Madan Singh wrote:Dear Qian,please try to use this code,
to select value from drop down in c#
new SelectElement(driver.FindElement(By.Id("ctl00_ContentPlaceHolder1_DDLMsg"))).SelectByValue("message");
You received this message because you are subscribed to a topic in the Google Groups "Selenium Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/selenium-users/nwWwPHU7Chs/unsubscribe?hl=en-US.
To unsubscribe from this group and all its topics, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.
To unsubscribe from this group and all its topics, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/4QvGHfqEyg0J.
Do me a favor. Follow the debugging steps I outlined in my last reply on IE 9 or 10, and let me know what happens. When you open the F12 Developer Tools, take special note of the browser mode and document mode when you try the test, please.
--
You received this message because you are subscribed to a topic in the Google Groups "Selenium Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/selenium-users/nwWwPHU7Chs/unsubscribe?hl=en-US.
To unsubscribe from this group and all its topics, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/dIlHu_sjp9oJ.
<option value="">- Select One -</option><option value="Internal" selected="selected">Internal Cost</option><option value="External">Project Cost</option>
SelectElement select = new SelectElement(driver.FindElement(By.Id("CostType")); /// Cerating SelectElement.