It appears that `a[href$="country/us"]` will pickup only country but in that case selector should be changed to be like: `(By.CSS_SELECTOR, 'a[href$="country/%(country_name)s"]` or it will work only for USA.