I am trying to get href attribute value from anchor tab on a page in my application using selenium Webdriver (Python) and the result returned has part stripped off.
Here is the HTML snippet -
<a class="nla-row-text" href="/shopping/brands?search=kamera&nm=Canon&page=0" data-reactid="790">
Here is the code I am using -
from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.common.action_chains import ActionChains driver = webdriver.Firefox() driver.get("xxxx") url_from_attr = driver.find_element(By.XPATH,"(//div[@class='nla-children mfr']/div/div/a)[1]").get_attribute("href") url_from_attr_raw = "%r"%url_from_attr print(" URL from attribute -->> " + url_from_attr) print(" Raw string -->> " + url_from_attr_raw)
The output I am getting is -
/shopping/brands?search=kamera&page=0
instead of -
/shopping/brands?search=kamera&nm=Canon&page=0 OR
/shopping/brands?search=kamera&nm=Canon&page=0
Is this because of the entity representation in the URL as I see part between entities stripped? Any help or pointer would be great
Thanks