Listed below is the code to reproduce the issue. It will work for 29 days as of November 24, 2022.
I'm trying to run this code:
iframe=driver.find_element(By.XPATH,"//iframe[contains(@src,thepath)]")
this is giving me different results than if I run:
iframe=driver.find_element(By.XPATH,"//iframe[contains(@src,'https://pianomarvel.com/uploads/editSlicings/86482')]")
where thepath equals 'https://pianomarvel.com/uploads/editSlicings/86482'
The code starts here:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
import time
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
driver=webdriver.Firefox()
driverversion = driver.capabilities['moz:geckodriverVersion']
print("driverversion",driverversion)
browserversion = driver.capabilities['browserVersion']
print("broserversion",browserversion)
#driver=webdriver.Chrome("/Users/carlkonopka/PycharmProjects/SeleniumTest/Driver/chromedriver")
driver.get("https://pianomarvel.com")
wait = WebDriverWait(driver, 10)
#driver.maximize_window()
time.sleep(5)
driver.find_element(By.LINK_TEXT, 'Login').click()
time.sleep(5)
#driver.find_element_by_name("Login").send_keys("LinkedIn Login")
driver.find_element(By.ID, 'input-component-1').send_keys("carlko...@gmail.com")
time.sleep(5)
element = driver.find_element(By.ID, 'input-component-2')
element.send_keys('Hlysp1rt30')
element.submit()
time.sleep(10)
#driver.find_element_by_xpath('//a[@href="'/en/nextgen/library'"]')
driver.find_element(By.XPATH,'/html/body/modal-container/div/div/app-welcome/div[2]/div[1]/div[2]/div[1]/button').click()
time.sleep(5)
driver.find_element(By.XPATH,'//a[contains(@href,"en/nextgen/library")]').click()
time.sleep(5)
#driver.close()
#driver.find_element(By.CLASS_NAME, 'close modal-close').click()
time.sleep(5)
#driver.find_element(By.CLASS_NAME, 'icon-option-level icon-level btn-border float-right').click()
#driver.find_element(By.CLASS_NAME, 'icon-option').send_keys(Keys.RETURN)
# Store the ID of the original window
original_window = driver.current_window_handle
driver.find_element(By.XPATH,'/html/body/app-root/div/app-main/div/app-sidebar/div/app-library/div/div/div/div/div/div[1]/div/div[2]/div[4]/div/img').click()
wait.until(EC.number_of_windows_to_be(2))
for window_handle in driver.window_handles:
if window_handle != original_window:
driver.switch_to.window(window_handle)
break
#driver.find_element(By.ID, 'search-box-title').send_keys("Take 5 3 and 4")
time.sleep(5)
#driver.find_element(By.XPATH,'//*[@id="search-box-title"]').send_keys("Take 5 3 and 4")
driver.find_element(By.XPATH,'//*[@id="search-box-title"]').send_keys("Morning Has Broken")
#driver.find_element(By.ID, 'new-song-button').click()
time.sleep(5)
driver.find_element(By.XPATH,'/html/body/div[1]/div[2]/div[3]/div[1]/div[2]/div/div[2]/div[1]/div/div[6]/img').click()
time.sleep(5)
# i=0
# persons = []
# for person in driver.find_elements(By.CLASS_NAME,'btn-default'):
# persons.append({person.text})
# print(persons)
#driver.switch_to().frame(1)
iframe = driver.find_element(By.XPATH,"//iframe[@class='popup']")
thesrc = driver.find_element(By.XPATH,"//iframe[@class='popup']").get_attribute("src")
thesong = thesrc.split('/', 5)[5]
print(thesong)
time.sleep(5)
driver.switch_to.frame(iframe)
time.sleep(5)
driver.find_element(By.XPATH,'//*[@id="edit-slicings"]').click()
time.sleep(5)
driver.switch_to.default_content()
time.sleep(5)
#driver.switch_to.default_content()
#time.sleep(5)
thepath='https://pianomarvel.com/uploads/editSlicings/'+thesong
print("the path is ",'"'+thepath+'"')
#driver.find_element(By.ID, "new-chopped-exercise").click()
#iframe=driver.find_element(By.XPATH("//iframe[contains(@src,'https://pianomarvel.com/uploads/editSlicings/86482')]"));
iframe=driver.find_element(By.XPATH,"//iframe[contains(@src,thepath)]")
#iframe=driver.find_element(By.XPATH("//iframe[contains(@src,'https://pianomarvel.com/uploads/editSlicings/86482')]"));
# iframe = driver.find_element(By.XPATH,"//iframe[@class='popup']")
print("Iframe using thepath is",iframe)
#iframe=driver.find_element(By.XPATH,"//iframe[contains(@src,thepath)]")
iframe=driver.find_element(By.XPATH,"//iframe[contains(@src,'https://pianomarvel.com/uploads/editSlicings/86482')]")
print("Iframe not using the path is",iframe)
quit()