PoweredByCoffee
PoweredByCoffee

Reputation: 1193

Python Selenium Finding Text

I'm struggling to understand why I can't find the text for this Javascript button.

Example of the button:

<a href="javascript:void(0)" onclick="LoadEvent(e,4,1,0,1); whl.setIframeScroll(0,0);" title="" class="Event__item">Event1</a>

I'm looping through each a tag but can't seem to find that "Event1" text.

rows = Driver.find_elements_by_xpath("//a")
for element in rows:
  print "a found"
  print element.text

It has loaded fully before the find_elements runs so as far as I understand it should be reading it.

I've tried variations like get_attribute('text') and get_attribute('innerText') as well.

I'd appreciate any suggestions on what I'm missing here.

Update:

This code does work. I hadn't spotted it was buried inside an iFrame so everything had loaded but Selenium wasn't targeting it.

Upvotes: 0

Views: 33

Answers (1)

PoweredByCoffee
PoweredByCoffee

Reputation: 1193

Updated question. Hadn't spotted the iFrame but the example code works.

Upvotes: 1

Related Questions