Selenium Forum: Functional And Regression Testing Tool.
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
Display results as :
Advanced Search
Latest topics
AEM Training | Free Online DemoWed Apr 21, 2021 5:45 pmazharuddin
c# PageFactory - issue initializing elementsFri Nov 01, 2019 8:40 pmthegoatboy
Selenium making automatic connection to random urlsMon Jul 08, 2019 12:58 pmrepairtechsolutions1
How can we design the custom framework in Selenium RCMon Jun 24, 2019 2:26 pmrandybonnettes
What are the new features in Selenium 3.0Tue Jun 18, 2019 5:37 pmpappyvicky
What are you using Selenium for? Fri Apr 12, 2019 3:52 amzhl
LIMITATIONS OF SELENIUMWed Apr 10, 2019 11:23 amswara
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Go down
avatar
shutey
Posts : 2
Join date : 2014-03-24

Validating 'random' text based on xpath Empty Validating 'random' text based on xpath

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?
avatar
ccox
Master
Master
Posts : 205
Join date : 2012-01-06
Age : 39
Location : Denver, CO

Validating 'random' text based on xpath Empty Re: Validating 'random' text based on xpath

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.
avatar
jgohel
Posts : 7
Join date : 2016-06-08

Validating 'random' text based on xpath Empty Re: Validating 'random' text based on xpath

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
Sponsored content

Validating 'random' text based on xpath Empty Re: Validating 'random' text based on xpath

Back to top
Permissions in this forum:
You cannot reply to topics in this forum