0

I need to click each of variation in this page.

My code clicking on first element but I am getting error when it trying to click on second element. Here is my code:

from selenium import webdriver
import time
url = 'https://www.zzounds.com/item--RNESEVENTYTWOMK2?siid=320037'
driver = webdriver.Chrome()
driver.get(url)

click = driver.find_elements_by_css_selector(".product-button")
for i in click:
    text = i.text
    print(text)
    i.click()
    time.sleep(3)

error which I am getting when trying to click on second element:

selenium.common.exceptions.WebDriverException: Message: target frame detached
  (Session info: chrome=102.0.5005.62)
hawaj
  • 296
  • 3
  • 12
  • https://stackoverflow.com/questions/58836020/webdriverexception-target-frame-detached-while-interacting-with-elements-within – Captain Caveman May 31 '22 at 21:17
  • If you are performing a click action in your loop, you are probably reloading the page and losing the elements. You would need to find the elements again after the page loads. – JD308 May 31 '22 at 21:29
  • Check out some of the answers to this thread, might help: https://stackoverflow.com/questions/58836020/webdriverexception-target-frame-detached-while-interacting-with-elements-within – Lobstergoat Jun 04 '22 at 00:12

0 Answers0