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

iteration with xpath to an select

View previous topic View next topic Go down

iteration with xpath to an select

Post by kame on Mon Feb 21, 2011 5:32 pm

Hi,

I'm trying to make selenium test for an dynamic created content (different element counts and ID's). With the test I want to find first SELECT that has not chosen value yet ("Please select") and hist ID contains "user_userprivassigns_attributes".

The problem is that getXpathCount returns for example 3 elements - and that is OK. The problem begins when I want to do anything on specified element from that list :
Code:
if(selenium.isElementPresent("//select[contains(@id, 'user_userprivassigns_attributes')]["+ i +"]")){
The element is not found !

Do anyone know what could be the problem or find another way to get to all the "SELECT" elements ?

More code for that problem:
Code:

[..]
int se = selenium.getXpathCount("//select[contains(@id, 'user_userprivassigns_attributes')]").intValue();
      
for(int i = 1; i <= se; i++){
      if(selenium.isElementPresent("//select[contains(@id, 'user_userprivassigns_attributes')]["+ i +"]")){
            String value = selenium.getSelectedLabel("//select[contains(@id, 'user_userprivassigns_attributes')]["+ i +"]");
                              
            if(value.compareTo("Please select") == 0)
            {            
               selenium.select("//select[contains(@id, 'user_userprivassigns_attributes')]["+ i +"]", "label="+ permission);
               sleep(1);
               break;
            }
         }         
      }
[..]

kame

Posts : 2
Join date : 2011-02-21

Back to top Go down

Re: iteration with xpath to an select

Post by Marthyn on Mon Feb 21, 2011 9:15 pm

do you mean to get all the options in a select? Cause that is getSelectOptions("") i think

Marthyn

Posts : 3
Join date : 2011-02-21

Back to top Go down

Re: iteration with xpath to an select

Post by kame on Mon Feb 21, 2011 9:29 pm

No... I want to select a specific option with a specific label (stored in "permission" variable), but first I need to find out the proper SELECT element.
Currently with help of my friend I have fixed part of the problem - when I add "xpath=(...)[i]" then I can check if element is present, get selected label but not choose one option in the SELECT.

I still need to find a working way to run select function on one of the SELECT elements from few ones.

Code:

for(int i = 1; i <= se; i++){
                        //here I check if the element is present - this works now with the xpath=
         if(selenium.isElementPresent("xpath=(//select[starts-with(@id, 'user_userprivassigns_attributes')])["+ i +"]")){
                        //now I check if the SELECT has specific value ("Please select") - this also works with xpath=
            String value = selenium.getSelectedLabel("xpath=(//select[starts-with(@id, 'user_userprivassigns_attributes')])["+ i +"]");                               
            if(value.compareTo("Please select") == 0)
            {         
                                      //my current problem - here the xpath doesn't work. Without it only the fist element can be found and selection can be made.
               selenium.select("xpath=(//select[starts-with(@id, 'user_userprivassigns_attributes')])["+ i +"]", "label="+ permission);
            

kame

Posts : 2
Join date : 2011-02-21

Back to top Go down

Re: iteration with xpath to an select

Post by Sponsored content Today at 7:13 am


Sponsored content


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