0

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.

1
  • Its strange. can you make your xpath more specific like //a[@class='Event__item'] and try ? Commented Mar 1, 2017 at 17:02

1 Answer 1

1

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

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.