How to Install a Windows Font Using C#

Unable to access Pop Up / iframe window using selenium python

I am using chromedriver version 100. Your code throws a NoSuchElementException. Thats because your driver tries to find an element which does not exist. So, what you need to do is to put time.sleep(4) statements after your click() statements (Your browser needs time to open the window/s). If you are done using the driver, use driver.quit().

Followed code worked for me:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time

driver = webdriver.Chrome('C:/Users/hamhatre/Desktop/chromedriver.exe')
driver.get("https://shopatsc.com/collections/playstation-5/products/ps5-horizon-forbidden-west")
driver.maximize_window()
driver.implicitly_wait(20)
elem = driver.find_element_by_xpath('//*[@id="pincode_input"]')
elem.send_keys("400708")
driver.find_element_by_xpath('//*[@id="check-delivery-submit"]').click()
driver.find_element_by_xpath('/html/body/div[2]/main/div[1]/div/div/div/div[2]/div[1]/form/div[3]/div/button[2]').click()
driver.find_element_by_xpath('//*[@id="checkout_email"]').send_keys('abc@gmail.com')
driver.find_element_by_xpath('//*[@id="checkout_shipping_address_first_name"]').send_keys('abc')
driver.find_element_by_xpath('//*[@id="checkout_shipping_address_last_name"]').send_keys('xyz')
driver.find_element_by_xpath('//*[@id="checkout_shipping_address_address1"]').send_keys('Rd1, Flat no 2, Apt 1')
driver.find_element_by_xpath(('//*[@id="checkout_shipping_address_address2"]')).send_keys('Nothing')
driver.find_element_by_xpath('//*[@id="checkout_shipping_address_city"]').send_keys('Mumbai')
driver.find_element_by_xpath('//*[@id="checkout_shipping_address_province"]').send_keys('Maharashtra')
driver.find_element_by_xpath('//*[@id="checkout_shipping_address_zip"]').send_keys('400708')
driver.find_element_by_xpath('//*[@id="checkout_shipping_address_phone_custom"]').send_keys('9876543210')

driver.find_element_by_id('continue_to_shipping_button_custom').click()
time.sleep(4)
driver.find_element_by_id('continue_button').click()
time.sleep(4)
driver.find_element_by_xpath('/html/body/div/div/div/main/div[1]/div/form/div[3]/div[1]/button').click()
time.sleep(4)

print(driver.title)
seq = driver.find_elements_by_tag_name('iframe')
print(seq)
print("No of frames present in the web page are: ", len(seq))

for index in range(len(seq)):
iframe = driver.find_elements_by_tag_name('iframe')[index]
driver.switch_to.frame(iframe)
driver.find_element_by_id('language-dropdown').click()

Selenium - Unable to find input elements inside iframe using SwitchTo()

wait=WebDriverWait(driver,10) 
wait.until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR,"#tab1")))

You are using Java use Python instead and waits.

driver.SwitchTo().Frame(driver.FindElement(By.id("tab1")));

Imports:

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

Unable to find element in iframes using Selenium WebDriver Python

The load chart layout is present inside nested iframes.

To handle dynamic element
Induce WebDriverWait() and frame_to_be_available_and_switch_to_it() following cssselector

Induce WebDriverWait() and wait for element_to_be_clickable() and following cssselector

driver.find_element_by_xpath("/html/body/div[5]/section/div[4]/div[1]/a").click()
print("live charts clicked")
WebDriverWait(driver,10).until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR,"iframe[id^='tvc_frame']")))
WebDriverWait(driver,10).until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR,"iframe[src$='GB']")))
WebDriverWait(driver,10).until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR,"iframe[id^='tradingview']")))
WebDriverWait(driver,10).until(EC.element_to_be_clickable((By.CSS_SELECTOR,"div.save-load-buttons>span.load"))).click()
print("successfully clicked load")

You need to import following libraries

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By

Selenium Webdriver (Python) - Unable to locate element inside nested iframes

The element is inside multiple <iframe> tags, you need to switch to them one by one. You should also maximize the window and use explicit wait as it take some time to load

from selenium.webdriver.support import expected_conditions as ec
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By

chrome_path = r"C:\Users\gh455\Downloads\chromedriver_win32\chromedriver.exe"
driver = webdriver.Chrome(chrome_path)
driver.maximize_window()
driver.get("https://www.nissanoflithiasprings.com/schedule-service")

wait = WebDriverWait(driver, 10)

# first frame - by css selector
wait.until(ec.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR, '[src^="https://consumer.xtime.com"]')))

# second frame - by ID
wait.until(ec.frame_to_be_available_and_switch_to_it('xt01'))

driver.find_element_by_id("new_customer_button")


Related Topics



Leave a reply



Submit