2

I'm a newbie in auto testing and got a problem.

Cannot get href in debug mode, try to check it on google.com, my code:

browser.get("https://google.com/")

def beta_check_href(self):

    elem = self.find_elements_by_xpath("//a[@href]")
    for el in elem:
        print elem.get_attribute("href")

What am I doing wrong? Thx!

1 Answer 1

4

You need to replace

for el in elem:
    print elem.get_attribute("href")

with

for el in elem:
    print el.get_attribute("href")

Note that elem is the list of WebElements while el is the single WebElement from elem list

Sign up to request clarification or add additional context in comments.

5 Comments

Thx, got it! But still have this problem
Which one? Share exception log
I see no problems on the screenshot. Can you clarify what is your desired and current output?
Maybe I asked the wrong question. Where on screenshot you can see href links?
No problem any more! Thx a lot!

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.