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
sulee
Active particpant
Active particpant
Posts : 14
Join date : 2010-12-27

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

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.apache.tools.ant.taskdefs.Sleep;
import org.openqa.selenium.internal.seleniumemulation.WaitForPageToLoad;

import com.thoughtworks.selenium.*;


public class small extends SeleneseTestCase {

public void setUp() throws Exception {
super.setUp("https://www.google.com", "*firefox");
}

public void testOpenGmail() throws Exception
{
selenium.windowMaximize();
selenium.open("/accounts/ServiceLogin?service=mail&passive=true&rm=false&continue=http%3A%2F%2Fmail.google.com%2Fmail%2F%3Fui%3Dhtml%26zy%3Dl&bsv=1eic6yu9oa4y3&scc=1<mpl=default<mplcache=2");
pause(5000);
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
{
super.tearDown();
}

}


P.S: the empty value is Ok. since there is no value of that id. Waiting guys, thanks again...
Advisor
Advisor
------------------------
------------------------
Posts : 387
Join date : 2009-07-30
Location : India
https://seleniumforum.forumotion.net

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

Fri Jan 28, 2011 8:15 pm
hi,

storeAllFields(variableName)


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