Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» how to connect DB in selenium webriver
Fri Oct 06, 2017 4:09 pm by anbarasi

» How find any text in browser screen and click on it?
Thu Oct 05, 2017 2:02 pm by sandeepkommineni

» Selenium Webdriver
Tue Oct 03, 2017 1:35 pm by PiyushBiswas

» GRID setup tutorial.
Wed Sep 27, 2017 4:29 pm by johnyapp

» Drag & Drop Between Windows Using Selenium Driver
Wed Sep 27, 2017 2:10 pm by 26rondel

» Check if window is closed / verify input
Sat Sep 23, 2017 10:21 pm by brainstir

» How to work on pages with AJAX in selenium?
Mon Sep 18, 2017 6:08 pm by azharuddin

» pause test until user press a key like F2
Wed Aug 09, 2017 11:10 pm by djnforce

» Selecting the input for auto populating element
Sat Jul 29, 2017 7:53 pm by kdabbara

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
avatar
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