Go down
Active particpant
Active particpant
Posts : 14
Join date : 2010-12-27

getAllFields() function returns only one element always, help!

on Mon Jan 10, 2011 3:20 pm
Hi all,

I am writing this piece of code to get the ids of the input fields on the page:

String buttons[] = selenium.getAllFields();
System.out.println("# buttons " + buttons.length);

for(int j =0; j {
System.out.println("id = " + buttons[j]);
System.out.println("value = " + selenium.getValue(buttons[j]));

And the page is log on page of gmail, there are 2 input fields: Email and password yet the function getAllFields() just returns the Email field. And the length is always 1. I also tried the getAllButtons() and getAllWindows() function but nothing changes. Length is still 1 altough there are more than 1 fields. can anybody help me? Thank you.

I am using Eclipse Helios and Junit3 tests. Platform is windows xp professional. And here is the full code and the output:

package com.example.tests;

import org.openqa.selenium.internal.seleniumemulation.WaitForPageToLoad;

import com.thoughtworks.selenium.*;

public class small extends SeleneseTestCase {

public void setUp() throws Exception {
super.setUp("", "*firefox");

public void testOpenGmail() throws Exception
System.out.println("Open successfull");

// TODO Auto-generated method stub
String fieldIDs[] = selenium.getAllFields();
System.out.println("# buttons " + fieldIDs.length);

for(int j =0; j {
System.out.println("id = " + fieldIDs[j]);
System.out.println("value = " + selenium.getValue(fieldIDs[j]));


public void tearDown() throws Exception


P.S: the empty value is Ok. since there is no value of that id. Waiting guys, thanks again...
Posts : 383
Join date : 2009-07-30
Location : India

Re: getAllFields() function returns only one element always, help!

on Fri Jan 28, 2011 8:15 pm


Returns the IDs of all input fields on the page.

If a given field has no ID, it will appear as "" in this array.
check if both the elements/field have assigned some id to it. Otherwise it'll return only number of elements which have id.

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