Hello,
I'm working in a scenario where i'm suppose to select three option list values from the option list.
I'm using the below code to select but it doesn't seem to be working.
WebDocument webdoc = new WebDocument("/dom[@domain='10.158.118.16:28443']");
SelectTag someSelectTag =webdoc.FindSingle(".//div/fieldset/div//table//tr/td/div//select[@class='v-select-select']");
IList<OptionTag> optTag = someSelectTag.Find<OptionTag>(".//option");
IList<String> p_Name = new List<String>{"ranorex queue 1fi","ranorex queue 2fi","ranorex queue 3fi"};
int c=0;
for(int i=0; i<p_Name.Count;i++)
{
for(int k=0; k<optTag.Count; k++)
{
if(optTag[k].InnerText.Contains(p_Name))
{
Delay.Seconds(1);
optTag[k].Selected=true;
Report.Log(ReportLevel.Success,optTag[k].InnerText + " " + "Queue name has been successfully removed from the update users at Queue list ");
c=1;
}
}
if(c==0){
Report.Log(ReportLevel.Failure,"Unable to remove from update users at Queue list");
}
}
Selecting multiple values from a option list
Selecting multiple values from a option list
You do not have the required permissions to view the files attached to this post.
Re: Selecting multiple values from a option list
Hi,
Please upload a Ranorex snapshot of the problematic list. Screenshot is unfortunately not helpful. Thanks.
Please upload a Ranorex snapshot of the problematic list. Screenshot is unfortunately not helpful. Thanks.
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
Ranorex explorer at Descartes Systems
Please add these details to your questions:
- Ranorex Snapshot. Learn how to create one >here<
- Ranorex xPath of problematic element(s)
- Ranorex version
- OS version
- HW configuration
Re: Selecting multiple values from a option list
Please find the attached Ranorex snapshot of list.
You do not have the required permissions to view the files attached to this post.
Re: Selecting multiple values from a option list
Hi,
Thanks, but this is not a Ranorex snapshot. It's just screenshot What I asked for is "snapshot" (rxsnp) file, as described here:
https://www.ranorex.com/help/latest/ran ... hot-files/
Thanks, but this is not a Ranorex snapshot. It's just screenshot What I asked for is "snapshot" (rxsnp) file, as described here:
https://www.ranorex.com/help/latest/ran ... hot-files/
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
Ranorex explorer at Descartes Systems
Please add these details to your questions:
- Ranorex Snapshot. Learn how to create one >here<
- Ranorex xPath of problematic element(s)
- Ranorex version
- OS version
- HW configuration
Re: Selecting multiple values from a option list
My bad haven't used the feature Ranorex snapshot.
please find the attached snapshot file.
please find the attached snapshot file.
You do not have the required permissions to view the files attached to this post.
Re: Selecting multiple values from a option list
Hi Noah,
Based on the look of things, you are making this a lot harder and complicated than it needs to be. Is there a reason why you are not using the Ranorex Repository and a simple recording module to select these three options? A recording module is just a visual version of the code that is much easier to manage & maintain. You can always view or convert actions to code if needed.
This example took me roughly 10 seconds to create and does exactly what you need.
Test Page: https://www.w3schools.com/tags/tryit.as ... t_multiple
Based on the look of things, you are making this a lot harder and complicated than it needs to be. Is there a reason why you are not using the Ranorex Repository and a simple recording module to select these three options? A recording module is just a visual version of the code that is much easier to manage & maintain. You can always view or convert actions to code if needed.
This example took me roughly 10 seconds to create and does exactly what you need.
Test Page: https://www.w3schools.com/tags/tryit.as ... t_multiple
You do not have the required permissions to view the files attached to this post.
Re: Selecting multiple values from a option list
Hi,
At first, I have to agree with N612. Many things are much easier (and much more reliably) to do using recording actions and testcase/smartfolder loops, instead of messing with code. For example, using hardcoded xpaths in code is a big NO...NO! This approach creates messy and unmaintainable test solution. If you insists on using code, pass the elements as repository items (or at very least xpaths as string parameters).
At second, what exactly does not work for you? Are there any errors thrown in code? Have you debugged the code? Does your code find the selectbox and its options and fills the lists?
And finally, I would suggest to use standard Click() method or at very least a SetAttributeValue, which sets the required selection attribute. Eventually, use 'Select' method, instead of 'Selected'.
Select not only selects the given element, but it also invokes a 'change' event. Hope this helps?
At first, I have to agree with N612. Many things are much easier (and much more reliably) to do using recording actions and testcase/smartfolder loops, instead of messing with code. For example, using hardcoded xpaths in code is a big NO...NO! This approach creates messy and unmaintainable test solution. If you insists on using code, pass the elements as repository items (or at very least xpaths as string parameters).
At second, what exactly does not work for you? Are there any errors thrown in code? Have you debugged the code? Does your code find the selectbox and its options and fills the lists?
And finally, I would suggest to use standard Click() method or at very least a SetAttributeValue, which sets the required selection attribute. Eventually, use 'Select' method, instead of 'Selected'.
Code: Select all
//use this...
optTag[k].Select();
//instead of this...
optTag[k].Selected=true;
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
Ranorex explorer at Descartes Systems
Please add these details to your questions:
- Ranorex Snapshot. Learn how to create one >here<
- Ranorex xPath of problematic element(s)
- Ranorex version
- OS version
- HW configuration