Display results as :

Rechercher Advanced Search

Latest topics
» Run automated selenium test scripts from JIRA ondemand
Fri Dec 08, 2017 12:40 pm by azharuddin

» New! Appium Desktop
Sat Nov 25, 2017 3:51 pm by azharuddin

» Selenium WebDriver Integration
Tue Nov 21, 2017 1:06 pm by azharuddin

» 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


Validating 'random' text based on xpath

View previous topic View next topic Go down

Validating 'random' text based on xpath

Post by shutey on Tue Mar 25, 2014 4:36 pm

Hi all, 

Sorry if this has been asked previously, but I've not been able to locate the thread that contains this question. 

I'm trying to expand on my knowledge of Selenium IDE as I look to do more and more with the tool, along with expanding the capabilities to meet our website validation needs. 

Basically, the scenario is event searching within a heavily content managed site. I've been able to build the script to pick up any event within a table and carry out a certain function, mitigating the need to have specific content in an ever changing environment. 

For content served within a table, i have managed to write the script as:

Command                                Target                      Value
open                                     /events
storeTable                        css=table.ce-list.1.0         eventA
storeTable                        css=table.ce-list.1.0         eventB
verifyElementPresent           link=${eventA}
verifyElementPresent           link=${eventB}
clickAndWait                      link=${eventA}

This allows me to select any event (or in this case the top two) that are served within the table. 

We then have another page that handles events based on a search, these are served via divs which means i am unable to use the same logic for these as above. In this case, i have had to use the xpath to select an item as it appears and not based on the item name (okay as long as there is one!).

Question 1 - Is it possible to use an IF statement within IDE? For example, "IF xpath isn't displayed do this". 
Answer - Yes, i am able to use IF statements with the aid of (http) However i'm still trying to get my head around the commands)

I am then trying to validate various text values upon event selection/ application. For example, the script so far looks like:

Command                                                                             Target                                                                          Value
waitForElementPresent           xpath=/html/body/div/div[4]/div/div[2]/div[2]/div/div/div/div[2]/div/p/span[2]/strong/a
click                                   xpath=/html/body/div/div[4]/div/div[2]/div[2]/div/div/div/div[2]/div/p/span[2]/strong/a
verifyText                                                            I would like you to arrange my place
click                                                                        id=registrationtype_1_e5
clickAndWait                                                              css=input.cesubmit

This then takes me to the event signup form, where some text and fee value is pre-populated based on content/ selection made. So, in this case, i have the event name and fee ("The registration fee for TEST EVENT is £25." appear at the top of the form which needs to be validated. 

Seeing as i'm using a random event based on the xpath to get to this point, this text will potentially change when new events get created via the CMS. So "Test Event" and a fee of "£25" could change to "Swimming with sharks" with a fee of "£300". What i need to do is to be able to validate a couple of things which i'm assuming will need to be done via xpath?

1) there is an event name being populated
2) there is an event fee being populated
3) i want to also be able to validate a specific fee, say a value of £25 or a string contains £

So this is where i ask how this is possible? 

So far, i'm using:

Command                                                               Target
verifyElementPresent         xpath=/html/body/div/div[4]/div/div/div[3]/div/form/div/fieldset/div/label/strong       (this is for event name)
verifyElementPresent         xpath=/html/body/div/div[4]/div/div/div[3]/div/form/div/fieldset/div/label/strong[2]   (this is for event fee)

If i knew the event was going to be the same each time, then i would have used the verifyText/ assertText commands and given it a specific target and value. If i use the assertText command, the target for the specific text item would be "//div[@id='theregistrationfeeforstrongeventnamestrongisstrongeventfeestrong']/label/strong[2]" and value £25 ~ could i use the same command/ target but the value would be anything containing £? If so, how?


Posts : 2
Join date : 2014-03-24

Back to top Go down

Re: Validating 'random' text based on xpath

Post by ccox on Thu Mar 27, 2014 9:46 am

Sorry if I'm a little lost in what you're asking.  If you are trying to assert that a String contains some text, you can use the getEval/storeEval commands to execute javascript.  With this you can use the .contains() function and return true if it is a match. Store your result as a variable and assert that variable is true.

Also it is helpful to only include relevant information to your question in your post.


Posts : 205
Join date : 2012-01-06
Age : 32
Location : Denver, CO

Back to top Go down

Re: Validating 'random' text based on xpath

Post by jgohel on Wed Jun 08, 2016 7:30 pm

your first code is wrong so I replace with this 

Command                                Target                      Value
open                                     /events
storeTable                        css=table.ce-list.1.0         eventA
storeTable                        css=table.ce-list.1.0         eventB
verifyElementPresent           ${eventA}
verifyElementPresent           ${eventB}
clickAndWait                       ${eventA}

Now its works better than previous


Posts : 7
Join date : 2016-06-08

Back to top Go down

Re: Validating 'random' text based on xpath

Post by Sponsored content

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