import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
driver = webdriver.Chrome()
driver.get(updatedCarLinks[0]) #This has a list of links that I need to look but will but this in a for loop later
time.sleep(2)
h1 = driver.find_element_by_xpath('//h1')
print(h1)
I keep getting the following error screen. I have been looking at it on other posts and can't seem to figure out why this error is happening.
selenium.common.exceptions.WebDriverException: Message: target frame detached
<--- Error
CodePudding user response:
Is the selenium crome driver compatible with you chrome version? Check the versions match or is supported by the driver.
CodePudding user response:
Most likely //h1
is under iframe
. If so, then to get rid of iframe you can try as follows:
WebDriverWait(driver, 20).until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR," select the iframe element correctly")))
#imports
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC