I would like to know how to webscrape a popup on a new page with selenium (or another framework). The Python code below clicks on a button then a new page opens but I don't know to copy/paste the promo code. Can you help ?
from selenium import webdriver
from time import sleep
from selenium.webdriver import ChromeOptions, Chrome
class Coupons_offers:
def stayOpen(self):
opts = ChromeOptions()
opts.add_experimental_option("detach", True)
driver = Chrome(chrome_options=opts)
def __init__(self):
self.driver = webdriver.Chrome()
self.driver.get("https://www.offers.com/scotch-porter/")
sleep(2)
self.driver.find_element_by_xpath('//button[@id="_evidon-banner-acceptbutton"]').click()
sleep(2)
self.driver.find_element_by_xpath('//body/div[@id="main"]/div[1]/div[1]/div[3]/div[1]/div[1]/div[1]/div[3]/div[1]/div[1]/a[1]').click()
sleep(4)
self.driver.get("https://www.offers.com/scotch-porter/#offer_id=4467763")