Reputation: 81
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.
Upvotes: 0
Views: 645
Reputation: 52665
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()
Upvotes: 2