- Sir Barnabas
- Posts : 3
Join date : 2013-06-03
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;
This doesn't seem to do anything though - it doesn't fail, just doesn't select the value.
Any ideas gratefully appreciated.
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.
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.
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.
- Sir Barnabas
- Posts : 3
Join date : 2013-06-03
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
I've posted the code below if that helps;
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
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);
};
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.
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.
- Sir Barnabas
- Posts : 3
Join date : 2013-06-03
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.
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.
Permissions in this forum:
You cannot reply to topics in this forum