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

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)51elliot.blogspot.cz/2008/02/selenium-ide-goto.html. 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?

shutey

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.

ccox
Master
Master

Posts : 205
Join date : 2012-01-06
Age : 31
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

jgohel

Posts : 7
Join date : 2016-06-08

Back to top Go down

Re: Validating 'random' text based on xpath

Post by Sponsored content Today at 7:14 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