1

So I'm trying to find this <ul> tag I found using inspect element on chrome:

<ul class = "jobs-search-results__list artdeco-list" itemtype="http://schema.org/ItemList"></ul>

This is what I tried in Python:

ul = driver.find_element_by_class_name("jobs-search-results__list artdeco-list")

Which should return the <ul> tag. Instead I get this error:

selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element:{"method":"class","selector":"jobs-search-results__list artdeco-list"}

I get the same error whether I use a tag/xpath/absolutepath selector.

Then I find out this element is not on the HTML page source, and so selenium can't find it. HTML Source (pastebin)

How do I go about finding this element if its not on the page source?

10
  • I’m not sure what the issue is here, you simply cannot parse something that doesn’t exist, right? Commented Dec 12, 2019 at 23:07
  • Do you expect the element to exist at some point? Commented Dec 12, 2019 at 23:36
  • So the general problem is the element is there when I use inspect element in the browser, but its not there in the HTML source, so I was just wondering if I can still get to it in the webdriver. Commented Dec 12, 2019 at 23:41
  • It's a bug in find_element_by_class_name. It's a known bug. Just switch to css. Commented Dec 13, 2019 at 1:35
  • 1
    Please do not post code as picture. Either you copy paste the code or include link to your test site. This helps people answering the question to reproduce the error easily. Commented Dec 13, 2019 at 5:25

1 Answer 1

1

The class of ul element that you are trying to get is changing while accessing site using Selenium. For this use the xpath as

//ul[contains(@class,'jobs-search__results')]

Now you can find ul element as

ul = driver.find_element_by_xpath("//ul[contains(@class,'jobs-search__results')]")
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.