python 和 selenium 的自动化 - 每次访问时都会更改框架名称

Automation with python and selenium - Frame name being changed on each access

我正在尝试使用 web selenium 进行自动化,但我在使用框架时遇到了很多问题

每次访问该站点,我需要的框架的名称和id都会更改,我的代码在python和下面的html中:

Html代码:

driver.switch_to_frame('mainsystem')
driver.switch_to_frame('mainform')
espera = WebDriverWait(driver, 10)
time.sleep(5)
frame_to_be_available_and_switch_to_it(('name','URLFrame8749307'))
time.sleep(2)
frame_to_be_available_and_switch_to_it(('name','mainform'))
time.sleep(2)

使用以 'URLFrame'

开头的部分 name/ID
frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR, '[name^="URLFrame"]'))