add the class name of your "a" element. In order to get an attribute value, you can use the method "get_attribute("element_name") linkElement = driver.find_element_by_xpath("//a[contains(@class,'THE CLASS NAME')]") attributeValue = linkElement.get_attribute("data-ftjson") stringElement = "\"newreq\":\"yes\"" if (stringElement in attributeValue): #do something else: #do something #or by json for this you need to import json jsonValue = attributeValue['newreq'] if jsonValue == 'yes': #do something else: #do something