Selenium - Using REGEXP / GLOB Patterns

357 views
Skip to first unread message

Shanmugavel.C

unread,
Oct 13, 2010, 2:32:45 AM10/13/10
to Selenium Users
I am using selenium RC with Visual Studio 2010 IDE and created tests.
Here i am facing a problem in identifying dynamic objects.
Object id looks like
"ctl00_MainEntry_AreaCreationControl_AreaGridView_ctl12_AreaNameFooterTextBox"
Here ctl12 is the part which is changing based on which row...But i
want to enter the value irrespective of row position..

//
*[@id='ctl00_MainEntry_AreaCreationControl_AreaGridView_ctl12_AreaNameFooterTextBox']
works fine in Selenium IDE when I click FIND button in IDE.
But below are not working in selenium IDE when I click FIND.
(1)
//
input[Contains(@id,'ctl00_MainEntry_AreaCreationControl_AreaGridView_ctl')
and Contains(@id,'_AreaNameFooterTextBox')]
(2)
//
input[@id,RegExp:'ctl00_MainEntry_AreaCreationControl_AreaGridView_ctl??
_AreaNameFooterTextBox']
(3)
//
input[@id,glob:'ctl00_MainEntry_AreaCreationControl_AreaGridView_ctl*_AreaNameFooterTextBox']
(4)
//
*[@id,glob:'ctl00_MainEntry_AreaCreationControl_AreaGridView_ctl*_AreaNameFooterTextBox']


Can anybody help me on this… How can I identify this object?

Thx in advance....
SCSVEL
scs...@gmail.com

Shaba K

unread,
Oct 13, 2010, 5:19:31 AM10/13/10
to seleniu...@googlegroups.com
Hi,
 
Does the XPath function starts-with work for you
 
-Shabana
 
 


 

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.


Stefan

unread,
Oct 13, 2010, 8:56:09 AM10/13/10
to Selenium Users
Hi,

Have you tried like this?

//
*[Contains(@id,'ctl00_MainEntry_AreaCreationControl_AreaGridView_ctl']/
INPUT/[Contains(@id,'_AreaNameFooterTextBox')]

Cheers,
Stefan

kmark

unread,
Oct 13, 2010, 2:24:31 PM10/13/10
to Selenium Users
If you specify just 1 xpath, Selenium IDE will find the first element
which matches the xpath. Since you said that ctl12 is the part which
changes based on which row, that leads me to believe that you have
multiple footer text boxes (or whatever you're clicking on).

Basically, even if you use an xpath like this:

//*[starts-with(@id,
'ctl00_MainEntry_AreaCreationControl_AreaGridView') and ends-with(@id,
'AreaNameFooterTextBox')]

If you have multiple area name footer text boxes, only the very first
one will get typed into. Selenium IDE will still 'know' about the
other ones, but it doesn't know which one YOU want to type stuff
into... so the reason for the ctl12 portion. BUT if you only have 1
area name footer text box and ONLY the ctl12 part changes, then the
above xpath should be sufficient I think.

Go look up Selenium IDE's UI-element feature, it is very useful in
mapping these elements to javascript code for greater flexibility and
ease of maintenance.

Shanmugavel.C

unread,
Oct 13, 2010, 11:17:16 PM10/13/10
to Selenium Users
Hi buddies,

First upon thank you all for your detailed reply....
I have another confusion?
Is the above solutions you guys told will work in any IDE (Visual
Studio 2010) or only Java based IDE (like Eclipse , NetBeans)?
I am using visual sudio 2010 IDE and extending my C# code generated
from selenium IDE...

---------------------------------------------------------------------------------------------------------------------------------------
> > input[@id,glob:'ctl00_MainEntry_AreaCreationControl_AreaGridView_ctl*_AreaN ameFooterTextBox']
> > (4)
> > //
> > *[@id,glob:'ctl00_MainEntry_AreaCreationControl_AreaGridView_ctl*_AreaNameF ooterTextBox']
>

Shanmugavel.C

unread,
Oct 14, 2010, 3:01:22 AM10/14/10
to Selenium Users
Hi buddies,

I tried your solutions but no luck.. here are the details
In my screen, a table view grid is there...

1. I am adding record in first row for a column(text box) and clicked
add button which will be in end of the same row.
2. after added, row containing that record wiill be read-only and
dynamically new row will get created to enter next record.
3. Here new row - textbox column id looks like
"ctl00_MainEntry_AreaCreationControl_AreaGridView_ctl02_AreaNameFooterTextBox"
-- this is "input" tag
Added record row(1st row) - column id looks like
"ctl00_MainEntry_AreaCreationControl_AreaGridView_ctl01_ByAreaNameLabel"
- this is "span" tag
But both starts-with same grid view only.
So i tried below command and not working.
//selenium.Type("//input[starts-
with(@id,'ctl00_MainEntry_AreaCreationControl_AreaGridView_ctl')]",
"test");
but if try below thing without mentioning tag type, its finding the
Added Row record. But i need new row to enter data not added row. So i
tried above command with input tag. but no luck...
//selenium.Type("//*[starts-
with(@id,'ctl00_MainEntry_AreaCreationControl_AreaGridView_ctl')]",
"test");

Hope you guys got my scenario to solve...
Can anybody help me on this?

thx in advance,
Shanmugavel
-----------------------------------------------------------------------------------------------------------------------------------------------------------------

Pavandeep Puddupakkam

unread,
Oct 13, 2010, 11:35:31 PM10/13/10
to Selenium Users
Here is an example you can use to verify the element on the page.
http://www.seleniumwiki.com/software-testing/selenium-rc/using-regular-expressions-in-xpath-selenium/
Reply all
Reply to author
Forward
0 new messages