java - Selenium Webdriver, how to validate a string in a url -
any validate parameter in url using selenium web driver + java
getcurrenturl() = https://www.loca.com/usa/test/#/xxx
my url string above, , based on url need enter value on loaded page, lets - have zipcode field enter zipcode value.
if url string contains 'usa' enter zipcode 12345 if url string contains canada enter zipcode ab1233
if using java, can like:
string zipcode = ""; string currenturl = "https://www.loca.com/usa/test/#/xxx" //this check make sure usa part of url, , doesn't exist part of url. if(currenturl.contains("/usa/")){ zipcode = "12345"; //same here canada } else if(currenturl.contains("/canada/"){ zipcode = "ab1233"; //you can continue pattern other countries } else if(currenturl.contains(...){ ... just put url string, , use string method contains check , see if usa in string. if is, use zip code, otherwise, else.
Comments
Post a Comment