2

I would want to split out particular text from the outerHTML attribute for a web link.

while Id is true:
    link = driver.find_element_by_xpath("//a[@id='bu:ms:all-sp:2']")
    href = link.get_attribute("outerHTML")  
    link.click()
    # This will load the link in the same page !
    self.assertIn(href, self.page.get_current_url())

When I print the href, output would be,

<a id="bu:ms:all-sp:8" href="/euro/tennis" class="Pointer"><span class="SportImg8"></span> Tennis <span class="NumEvt">51</span></a>

I would want to split this and assert the value of href alone (/euro/tennis) with the current URL.

Could anyone please help me out here ?

0

1 Answer 1

3

Get href attribute instead of outerHTML:

href = link.get_attribute("href")  
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.