0

This code works fine on another site. But it's not working for this site. Please help me find the cause, the error...

The code must fulfill a click on one of the ad units.
Ad units are generated in index.html with JavaScript. After loading page pictures and links are displayed. I need to perform a click on one of them.

from selenium import webdriver
import time
browser=webdriver.Firefox()
browser.get('http://momond.ml')
browser.find_element_by_xpath("//a[contains(@href,'xpicw.top')]").click()
browser.quit()

xpicw.top is a part of link ad units links.

1 Answer 1

2

Your link located inside an iframe. To click it you should switch to that frame first:

browser.switch_to_frame(browser.find_element_by_xpath('//iframe[starts-with(@class,"tblock_")]'))
browser.find_element_by_xpath("//a[contains(@href,'xpicw.top')]").click()
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.