Globbing Patterns - selenium Matching Text Patterns
Globbing Patterns is the one of the matching text patterns in selenium. You can describe expected text pattern with command's target column and can use it with verify and assert commands. We can use globbing pattern when expected text string is dynamic and can use with commands like verifyTitle, assertText, verifyTextPresent, assertTextPresent etc.
When you are getting dynamic text every time when you reload page or taking some action in that case
Globbing Pattern is very useful. It will tell text pattern to selenium. Let we learn with example so that you can understand it better.
Bellow is the example script where i have described how to write text pattern using Globbing Patterns. You can define Globbing Pattern with starting word "glob:".
New Test | ||
Command | Target | Value |
open | http://www.software-testing-tutorials-automation.com/ | |
verifyTitle | Software testing tutorials and automation | |
verifyTitle | glob:Software * tutorials * automation | |
open | http://www.software-testing-tutorials-automation.com/2013/06/selenium-for-testing-alert-on-page.html | |
verifyTitle | glob:Software * tutorials * automation* | |
verifyTextPresent | Alert testing with selenium is not much hard. In Selenium IDE plug in, there are many commands | |
verifyTextPresent | glob:Alert testing with selenium is * In Selenium IDE plug in*are many commands |
In above example, first "verifyTitle" command will verifies the title "Software testing tutorials and automation" of the page. 2nd "verifyTitle" command will also verify page title but with the given Globbing title text Pattern "glob:Software * tutorials * automation". Here actual page title is not "Software * tutorials * automation" but it will work because i have written it with Globbing Patterns (Used word "glob:" and * in between title text). Now you can understand how i have used Globbing Pattern with "verifyTextPresent" command in above example? I think yes. Compare both comand's target text. Both are not same but both will work and pass your test.
Both these are just examples. You can use it with other commands also. Main thing is you should know how to write Globbing Pattern.
thanks for sharing the information.. its helpful.. I think it works only in IDE and not webDriver ?
ReplyDelete