Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» FlexMonkium Download Not available under Gorillalogic site
Thu Dec 08, 2016 5:40 pm by bhanu.praveen

» Selenium Script issue
Tue Dec 06, 2016 9:48 pm by njain213

» Difference between QTP, Selenium and Silk test
Tue Dec 06, 2016 7:58 pm by jessicacyrus1

» Where does selenium script pick browser from
Tue Dec 06, 2016 1:52 pm by janbaskt

» Safari throws an HTTP ERROR: 404
Tue Dec 06, 2016 1:51 pm by janbaskt

» Access Denied Error in Selenium RC
Tue Dec 06, 2016 1:51 pm by janbaskt

» Automating Flex application through selenium webdriver
Fri Dec 02, 2016 2:06 pm by abhinay.krs

» Starting with Selenium, what is Selenium?
Mon Nov 28, 2016 4:00 pm by Foma

» Getting started with Selenium
Mon Nov 28, 2016 3:23 pm by Rebbelx

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

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

View previous topic View next topic Go down

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

Post by sulee 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.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...

sulee
Active particpant
Active particpant

Posts : 14
Join date : 2010-12-27

Back to top Go down

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

Post by Adviser on 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

Adviser
------------------------
------------------------

Posts : 379
Join date : 2009-07-30
Location : India

http://seleniumforum.forumotion.net

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

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