element.options is undefined error

82 views
Skip to first unread message

kamundse

unread,
Jun 10, 2010, 12:53:50 PM6/10/10
to tellurium-users
Hi,

I have just written my first Tellurium test case and I am seeing the
following error on execution:

com.thoughtworks.selenium.SeleniumException: ERROR: Command execution
failure. Please search the Tellurium User Group at
http://groups.google.com/group/tellurium-users for error details from
the log window. The error message is: element.options is undefined
at
com.thoughtworks.selenium.HttpCommandProcessor.throwAssertionFailureExceptionOrError(HttpCommandProcessor.java:
97)
at
com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:
91)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
...

I searched here and did a Google search but I was not able to find any
error that quite matched this. Any ideas what it happening?

The code is pretty simple.

public void defineUi() {
ui.Form(uid: "createAccount", clocator: [tag: "form", method:
"post", action: "https://www.mysite.com/SignupProc.jsp"])
{
InputBox(uid: "emailInput", clocator: [tag: "input", type:
"text", name: "email"])
InputBox(uid: "passwordInput", clocator: [tag: "input", type:
"password", name: "newPassword"])
InputBox(uid: "passwordConfirmInput", clocator: [tag: "input",
type: "password", name: "newPassword2"])
InputBox(uid: "firstNameInput", clocator: [tag: "input", type:
"text", name: "firstName"])
InputBox(uid: "lastNameInput", clocator: [tag: "input", type:
"text", name: "lastName"])
Selector(uid: "countrySelector", clocator: [tag: "select", name:
"country"])
Selector(uid: "mediaSelector", clocator: [tag: "select", id:
"intendedMedia", name: "intendedMedia"])
CheckBox(uid: "interactPrefCheckBox", clocator: [tag: "input",
type: "checkbox", value: "true", name: "interactPrf", class:
"checkbox"])
InputBox(uid: "referrerCodeInput", clocator: [tag: "input", type:
"text", name: "referrerCode"])
SubmitButton(uid: "createMyAccountSubmit", clocator: [tag:
"input", type: "submit", value: "Create My Account", name: "submit",
id: "create_account"])
}
}

All I am trying to test right now is mediaSelector and the first test
is just confirming that it contains types to select:

public class CreateAccountTest extends TelluriumJUnitTestCase
{
private static CreateAccountModule uiMod;

@BeforeClass
public static void initUi()
{
uiMod = new CreateAccountModule();
uiMod.defineUi();

}

@Before
public void testingSetUp()
{
connectSeleniumServer();
connectUrl("http://www.mysite.com/Signup.jsp");
}

@Test
public void testMediaSelectorBox()
{
String[] mediaTypes = uiMod.getMediaTypes();

Assert.assertNotNull(mediaTypes);
}

Thanks for any help.

-Kristin

Jian Fang

unread,
Jun 10, 2010, 1:04:27 PM6/10/10
to telluri...@googlegroups.com
Seems it cannot find the options attribute for the selector  "mediaSelector". Could you do a quick test by
adding the following line

uiMod.diagnose("createAccount.mediaSelector");

before the line

String[] mediaTypes = uiMod.getMediaTypes();

and see what happens?

Thanks,

Jian



--
You received this message because you are subscribed to the Google Groups "tellurium-users" group.
To post to this group, send email to telluri...@googlegroups.com.
To unsubscribe from this group, send email to tellurium-use...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/tellurium-users?hl=en.


kamundse

unread,
Jun 10, 2010, 5:49:30 PM6/10/10
to tellurium-users
Wow, ok that spit out a lot of output. The first part before it
showed what appears to be the source for the page was:

14:37:37.359 INFO - Got result: OK,[{"sequ":
2,"name":"getDiagnosisResponse","returnType":"STRING","returnResult":
{"uid":"createAccount.mediaSelector","count":2,"matches":["<div id=
\"intendedMedia\">\u000a<label for=\"intendedMedia\" style=\"width:
95%;\"><span class=\"required_mark\">* </span>What type of media are
you considering publishing?</label>\u000a<select name=\"intendedMedia
\" id=\"intendedMedia\">\u000a<option value=\"-1\" selected=\"selected
\">Please Choose One</option><option value=\"0\">Book</option><option
value=\"1\">Audio</option><option value=\"2\">Video</option><option
value=\"3\">A combination of media</option><option value=\"4\">I'm not
sure yet</option></select>\u000a</div>","<select name=\"intendedMedia
\" id=\"intendedMedia\">\u000a<option value=\"-1\" selected=\"selected
\">Please Choose One</option><option value=\"0\">Book</option><option
value=\"1\">Audio</option><option value=\"2\">Video</option><option
value=\"3\">A combination of media</option><option value=\"4\">I'm not
sure yet</option></select>"]

Then after the page source:

Diagnosis Result for createAccount.mediaSelector

-------------------------------------------------------

Matching count: 2

Match Elements:

--- Element 1 -->

<div id="intendedMedia">
<label for="intendedMedia" style="width: 95%;"><span
class="required_mark">* </span>What type of media are you considering
publishing?</label>
<select name="intendedMedia" id="intendedMedia">
<option value="-1" selected="selected">Please Choose One</
option><option value="0">Book</option><option value="1">Audio</
option><option value="2">Video</option><option value="3">A combination
of media</option><option value="4">I'm not sure yet</option></select>
</div>

--- Element 2 -->

<select name="intendedMedia" id="intendedMedia">
<option value="-1" selected="selected">Please Choose One</
option><option value="0">Book</option><option value="1">Audio</
option><option value="2">Video</option><option value="3">A combination
of media</option><option value="4">I'm not sure yet</option></select>

And:

Closest:


Closest:

--- closest element 1 ---

<div id="intendedMedia">
<label for="intendedMedia" style="width: 95%;"><span
class="required_mark">* </span>What type of media are you considering
publishing?</label>
<select name="intendedMedia" id="intendedMedia">
<option value="-1" selected="selected">Please Choose One</
option><option value="0">Book</option><option value="1">Audio</
option><option value="2">Video</option><option value="3">A combination
of media</option><option value="4">I'm not sure yet</option></select>
</div>

--- closest element 2 ---

<select name="intendedMedia" id="intendedMedia">
<option value="-1" selected="selected">Please Choose One</
option><option value="0">Book</option><option value="1">Audio</
option><option value="2">Video</option><option value="3">A combination
of media</option><option value="4">I'm not sure yet</option></select>

The page source for the selector is:

<div id="intendedMedia">
<label for="intendedMedia" style="width: 95%;"><span
class="required_mark">* </span>What type of media are you considering
publishing?</label>
<select name="intendedMedia" id="intendedMedia">
<option value="-1" selected="selected">Please Choose One</
option><option value="0">Book</option><option value="1">Audio</
option><option value="2">Video</option><option value="3">A combination
of media</option><option value="4">I'm not sure yet</option></select>
</div>
<span class="field_error"> </span>

It only appears once in the page source.

Thanks,

-Kristin

Jian Fang

unread,
Jun 10, 2010, 8:06:36 PM6/10/10
to telluri...@googlegroups.com
I see your problem. You have the same id "intendedMedia" used in two places
of the html source. Id should be unique in a html page.

To workaround your problem, you should remove the id attribute from your UI module definition so that Tellurium will not search the element by ID. That is to say, you can use

  Selector(uid: "mediaSelector", clocator: [tag: "select", name: "intendedMedia"])

in your UI module definition

You use can use partial match, i.e.,.

Selector(uid: "mediaSelector", clocator: [tag: "select", id: "*intendedMedia", name: "intendedMedia"])

In this way, Tellurium will use all attributes instead of the id alone.

Let us know if this works for you.

Thanks,

Jian

-Kristin

kamundse

unread,
Jun 10, 2010, 8:32:21 PM6/10/10
to tellurium-users
Oh I see, the div tag's id is confusing it. Ok. Thanks!

-Kristin

Jian Fang

unread,
Jun 10, 2010, 9:53:09 PM6/10/10
to telluri...@googlegroups.com
From the discussion, you can see that the

diagnose(uid)

method is really powerful. But this method only works for a single UI element. If you use Tellurium new Engine, the following method will diagnose/validate the whole UI module for you.

validate(uid)

Thanks,

Jian

On Thu, Jun 10, 2010 at 8:32 PM, kamundse <avatar...@gmail.com> wrote:
Oh I see, the div tag's id is confusing it.  Ok.  Thanks!

-Kristin

Reply all
Reply to author
Forward
0 new messages