Quantcast
Channel: Active questions tagged frames - Stack Overflow
Viewing all articles
Browse latest Browse all 55

Unable to locate element within frame(s) in Selenium Webdriver

$
0
0

Relatively new to Python and I'm looking to create an automation that goes to this site, and clicks a button. For some reason its very tough for me to find the element I'm looking for.

Here is an example of the script:

import timefrom selenium import webdriverfrom selenium.webdriver.chrome.options import Optionsfrom selenium.webdriver.common.by import Byfrom selenium.webdriver.support.ui import WebDriverWaitfrom selenium.webdriver.support import expected_conditions as ECfrom selenium.webdriver.common.keys import Keysfrom webdriver_manager.chrome import ChromeDriverManageroptions = Options()#options.add_argument("start-maximized")driver = webdriver.Chrome(options=options)chrome_driver_path = ChromeDriverManager().install()#import logging#logging.basicConfig(level=logging.DEBUG)driver.maximize_window()#driver.implicitly_wait(10)driver.get("http://listyourself.net")driver.switch_to.frame(0)#driver.switch_to.frame("frame_name_or_id")#element = WebDriverWait(driver, 20).until(#   EC.visibility_of_element_located((By.XPATH, '//*[@id="myNavbar"]/ul/li[2]/a'))#)element_inside_frame = WebDriverWait(driver, 10).until(    EC.presence_of_element_located((By.XPATH,"#//a[contains(text(), 'individual')]")))element_inside_frame.click()#driver.find_element(By.XPATH, '/html/body/div/div[1]/nav/div/div[2]/ul/li[2]/a').click()#//a[contains(text(), 'individual')]#element = driver.find_element(By.XPATH, '//*[@id="myNavbar"]/ul/li[2]/a')#element.click()#logging.info('element clicked successfully')#driver.switch_to.default_content()driver.switch_to.parent_frame()time.sleep(5)driver.quit()

The script gets to the site fine but it waits the entire 10 seconds and gives me a "elenium.common.exceptions.TimeoutException: Message: Stacktrace" error & im assuming its because its unable to find the element for the "individual" button im looking to click on.

As you can see from the script i've tried almost everything, xpath, (theres no id or name for the element, text, tried creating my own xpath, all of which were confirmed to exist and be 1on1 in the console.

How do i troubleshoot this? I'm at a stand still and all of the other stackoverflow posts did not help.

Here is the website code for refrence.

enter image description here

The highlighted element is what im trying to click on, the "individual" button. I am using chrome on a mac and updated versions of selenium, webdriver, and pip. Please advise. Thank you

I've tried all of the troubleshooting methods to no success.


Viewing all articles
Browse latest Browse all 55

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>