0

I want the link of the button when they are clicked or those elements of button

from selenium import webdriver
browser=webdriver.Chrome()
browser.get("http://fileml.com/l/0wC1#/offers")
elemlist=browser.find_elements_by_xpath("ul/li/a")

But elemlist is also empty neither I can get those elements nor I can get the href But once it clicked it opens some url

So is there any what that I can atleast get elements of those buttons

4
  • please include the source from which you're trying to scrape Commented Aug 28, 2017 at 15:51
  • o sorry for that i forgot Commented Aug 28, 2017 at 15:53
  • Please don't edit your question after it's answered... in this case, you edited the question to put the answer inside which makes the question not make any sense because it should have worked. Commented Aug 28, 2017 at 18:14
  • actually the answer was edited too .The answer that I got first was just adding // and to make sure that it was not that solution that resolved that error and // didnot worked well so i edited.Sorry for that if I violated StackOverflow policy Commented Aug 28, 2017 at 18:36

1 Answer 1

1

You get empty list because your XPath expression is incorrect.

Try below:

"//ul/li/a"

Note that "//ul" means unordered list somewhere in the DOM while just "ul" means unordered list which is the root element

Also make sure that you switched to iframe before searching for ul:

browser.switch_to.frame("offer-iframe")
Sign up to request clarification or add additional context in comments.

4 Comments

Required list located inside an <iframe id="offer-iframe">...</iframe>. It contains its own DOM. You need to switch to that iframe to be able to access elements from iframes' DOM
I dont know about DOM.Can you just explain in brief a little
Simply put, DOM is HTML tree

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.