Selenium Forum: Functional And Regression Testing Tool.
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
Display results as :
Advanced Search
Latest topics
AEM Training | Free Online DemoWed Apr 21, 2021 5:45 pmazharuddin
c# PageFactory - issue initializing elementsFri Nov 01, 2019 8:40 pmthegoatboy
Selenium making automatic connection to random urlsMon Jul 08, 2019 12:58 pmrepairtechsolutions1
How can we design the custom framework in Selenium RCMon Jun 24, 2019 2:26 pmrandybonnettes
What are the new features in Selenium 3.0Tue Jun 18, 2019 5:37 pmpappyvicky
What are you using Selenium for? Fri Apr 12, 2019 3:52 amzhl
LIMITATIONS OF SELENIUMWed Apr 10, 2019 11:23 amswara
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Go down
avatar
Sir Barnabas
Posts : 3
Join date : 2013-06-03

Attempting to drop down value using Selenium IDE user extension Empty Attempting to drop down value using Selenium IDE user extension

Mon Jun 03, 2013 10:41 pm
Hi,

Selenium newbie alert.

I'm trying to set a drop down value using a javascript user extension for Selenium IDE.

Everything works fine up until passing the value back where I was trying to use this;

Code:
this.browserbot.selectOption(element, var);

This doesn't seem to do anything though - it doesn't fail, just doesn't select the value.

Any ideas gratefully appreciated.
avatar
tarun3kumar
Master
Master
Posts : 186
Join date : 2012-02-14
http://seleniumtests.com

Attempting to drop down value using Selenium IDE user extension Empty Re: Attempting to drop down value using Selenium IDE user extension

Tue Jun 04, 2013 10:45 am
You can use built-in select method.
Here is the description copied from Selenium IDE -

select(selectLocator, optionLocator)
Arguments:

selectLocator - an element locator identifying a drop-down menu
optionLocator - an option locator (a label by default)

Select an option from a drop-down using an option locator.

Option locators provide different ways of specifying options of an HTML Select element (e.g. for selecting a specific option, or for asserting that the selected option satisfies a specification). There are several forms of Select Option Locator.

label=labelPattern: matches options based on their labels, i.e. the visible text. (This is the default.)
label=regexp:^[Oo]ther
value=valuePattern: matches options based on their values.
value=other
id=id: matches options based on their ids.
id=option1
index=index: matches an option based on its index (offset from zero).
index=2

If no option locator prefix is provided, the default behaviour is to match on label.
avatar
Sir Barnabas
Posts : 3
Join date : 2013-06-03

Attempting to drop down value using Selenium IDE user extension Empty Re: Attempting to drop down value using Selenium IDE user extension

Tue Jun 04, 2013 4:22 pm
Hi,

thanks for the info, however I am still struggling to get this to work.

In brief, I am trying to automate a password screen whereby the user is requested to enter 3 characters e.g. 1st, 2nd & 3rd selected at random from their password and the characters are selected from a drop down list.

For testing purposes, the password is always the same but the characters requested change on each login.

I've created a user extension to try and do this, and everything is fine up until actually selecting the value in the drop-down which just I just can't seeem to get it to do Crying or Very sad

I've posted the code below if that helps;

Code:
Selenium.prototype.doSetMPCharOne = function(locator) {

var element = this.page().findElement(locator);

/* Determines which character is being requested
var position = element.title.charAt(10);

var char = " ";

switch(position)

    {
    case "1":
      char="p"; 
    break;
    etc..., etc...
    };

  this.browserbot.select(element, char);

};
avatar
tarun3kumar
Master
Master
Posts : 186
Join date : 2012-02-14
http://seleniumtests.com

Attempting to drop down value using Selenium IDE user extension Empty Re: Attempting to drop down value using Selenium IDE user extension

Wed Jun 05, 2013 1:19 pm
This feature seems a little weird.
It seem it is an auto-suggest list, if it is then I would suggest using "sendKeys"
and then clicking on the element which appears in auto suggest list.
avatar
Sir Barnabas
Posts : 3
Join date : 2013-06-03

Attempting to drop down value using Selenium IDE user extension Empty Re: Attempting to drop down value using Selenium IDE user extension

Wed Jun 05, 2013 11:56 pm
Just could not get this to work, but got round it in the end by putting the relevant character in storedVar and then using the standard select command in the IDE with the storedVar as the value.

I'm sure there's probably a better way of doing it but this seems to have done the trick for now.

Thanks for your suggestions all the same.
Sponsored content

Attempting to drop down value using Selenium IDE user extension Empty Re: Attempting to drop down value using Selenium IDE user extension

Back to top
Permissions in this forum:
You cannot reply to topics in this forum