Dynamic Drop Down Selection

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Dynamic Drop Down Selection

ccox
I am trying to automate an application that has a drop down that dynamically populates with customer names.  The drop down does not actually populate with data until it is selected.  When running through the script it thinks it selects something and passes the step, but nothing actually happens.  I have tried selecting the index, label, value, storing the name and selecting it, clickAt, mouseDown, keyPress, focus, etc. and nothing seems to work.  Any suggestions?

Here's the code:

<select index="0" onchange="nc.validate.onChange(this);nc.bizrules.showField(this);" onblur="nc.validate.validateField(this);" onfocus="nc.bizrules.appraisalContactNameOnFocus(this)" validatesect="appraisal" oldvalue="" ctrltype="cbo" isdirty="N" id="cboAIContactName0" name="ctl00$cphMain$ucAppraisal0$cboAIContactName0">
       

</select>
<option value="">--‌·Select‌·--</option>
<option value="-1001">Customer Name</option>
<option value="-1002">Customer Name2</option>
<option value="-1002">Customer Name3</option>
<option value="OTHER">Other</option>
</select>
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic Drop Down Selection

softwaretestingforum
Administrator
Could you post your Selenium Code also, as it looks a little odd that there are two end tags for select -

</select>

Also what are you referring here -

The drop down does not actually populate with data until it is selected.

If you mean that drop down values are populated only after some operation then I would suggest to wait conditionally for the drop down values to be populated before going ahead with selecting a value in drop down.
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic Drop Down Selection

ccox
Ignore the extra </select>.  That was just a copy/paste typo.  

This is how it looks as recorded:
selenium.select("id=cboAIContactName0", "label=Other");

I have tried these and many others:
selenium.select("id=cboAIContactName0", "index=1");
selenium.select("id=cboAIContactName0", "value=Other");

From what I gathered, this application doesn't populate the drop down until the drop down is actually selected or has focus.  When it does this, it pulls the customers associated to a specific record into the drop down.  The strange thing is I can store what is in the drop down, but Selenium isn't selecting it

[info] Executing: |storeText | id=cboAIContactName0 | contactName |
[info] Executing: |echo | ${contactName} | |
[info] echo: -- Select --Laurence FrancisCathleen FrancisOther






 
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic Drop Down Selection

                       
On execution it would look as -

    [info] Executing: |storeEval | javascript{"window.document.getElementById('cboAIContactName0').value = Other"} | |
    [info] script is: window.document.getElementById('cboAIContactName0').value = Other

Let us know if this works.



~ seleniumtests.com
softwaretestingforum
Administrator
So looks like that despite drop down values are populated the selection is not triggered using Sel IDE.
Can you try executing java script as -

storeEvaljavascript{"window.document.getElementById('cboAIContactName0').value = Other"}
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic Drop Down Selection

ccox
This is what I get:

[info] Executing: |storeEval | javascript{"window.document.getElementById('cboAIContactName0').value = Other"} | selectContact |
[info] script is: window.document.getElementById('cboAIContactName0').value = Other
[error] Threw an exception: Other is not defined

That execution fails, but it does return what you said it should.
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic Drop Down Selection

softwaretestingforum
Administrator
Can you try with a different value?
Don't use select as we are using js execution for same.
Also can you make sure drop down is populated with value to be selected before you execute the js
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic Drop Down Selection

ccox
"Other" is always an option in the drop down, but populates when the customer names do.  

[info] Executing: |storeText | id=cboAIContactName0 | names |
[info] Executing: |echo | ${names} | |
[info] echo: -- Select -- Courtney Sacks Muriel Sacks Other

[info] Executing: |storeEval | javascript{"window.document.getElementById('cboAIContactName0').value = Courtney Sacks "} | contactName |
[info] script is: window.document.getElementById('cboAIContactName0').value = Courtney Sacks
[error] Threw an exception: missing ; before statement

It looks like the values are there before the js is executed.
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic Drop Down Selection

softwaretestingforum
Administrator
we are close then.

I see there is one space after 'Sacks ' and quotation "
Could you remove it. Also don't use the variable name - contactName as you would not really be storing any value with this evaluation.
Could you try this and let us know?
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic Drop Down Selection

ccox
That gives me the same error:
[info] Executing: |storeEval | javascript{"window.document.getElementById('cboAIContactName0').value = Susanna PimentelIgnacio"} | |
[info] script is: window.document.getElementById('cboAIContactName0').value = Susanna PimentelIgnacio
[error] Threw an exception: missing ; before statement
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic Drop Down Selection

softwaretestingforum
Administrator
Is there any way for me to access the application?
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic Drop Down Selection

ccox
Unfortunately there isn't.