当我想滚动
时遇到了一个问题,我将代码从我所在的位置附加到框架并更改,以及我当前尝试滚动的方式:
.
.
.
driver.find_element(By.XPATH,'//*[@id ="nivel4_11_5_3_1_2"]').click() # Consultar factura y nota
WebDriverWait(driver,60).until(EC.frame_to_be_available_and_switch_to_it(('iframeApplication'))) #Cambiar a iframe consulta de facturas
for z in categories_1:
WebDriverWait(driver,10).until(EC.element_to_be_clickable((By.XPATH,'/html/body/div[1]/table/tbody/tr/td/div/div/form/table/tbody/tr/td/table/tbody/tr/td/table[2]/tbody/tr[1]/td[3]/div/div[2]/input')))
driver.find_element(By.XPATH,'/html/body/div[1]/table/tbody/tr/td/div/div/form/table/tbody/tr/td/table/tbody/tr/td/table[2]/tbody/tr[1]/td[3]/div/div[2]/input').send_keys(periodoactual[0]) #Rellenar fecha inicio
driver.find_element(By.XPATH,'/html/body/div[1]/table/tbody/tr/td/div/div/form/table/tbody/tr/td/table/tbody/tr/td/table[2]/tbody/tr[2]/td[3]/div/div[2]/input').send_keys(periodoactual[1]) #Rellenar fecha final
driver.find_element(By.XPATH,'/html/body/div[1]/table/tbody/tr/td/div/div/form/table/tbody/tr/td/table/tbody/tr/td/table[2]/tbody/tr[3]/td[3]/div/div[3]/input[1]').clear() #Limpiar campo de tipo de consulta
driver.find_element(By.XPATH,'/html/body/div[1]/table/tbody/tr/td/div/div/form/table/tbody/tr/td/table/tbody/tr/td/table[2]/tbody/tr[3]/td[3]/div/div[3]/input[1]').send_keys('FE Recibidas') #Llenar con tipo de consultas
driver.find_element(By.XPATH,'/html/body/div[1]/table/tbody/tr/td/div/div/form/table/tbody/tr/td/table/tbody/tr/td/table[3]/tbody/tr[1]/td[1]/span/span/span/span[3]').click() #Clickear en buscar comprobantes
sleep(5)
driver.switch_to.default_content()
WebDriverWait(driver,20).until(EC.element_to_be_clickable((By.ID,'iframeApplication')))
marco= driver.find_element(By.ID,'iframeApplication')
driver.execute_script('arguments[0].scrollIntoView({block: "center"})', marco)
print(len(driver.find_elements(By.LINK_TEXT,'Descargar Factura (XML)')))
我想强调开关工作正常,因为我可以检索信息并在框架内单击,我需要的是向下滚动
问题如下:为了让它加载iframe中的所有信息,我需要滚动,这样元素的打印计数返回64而不是25,这就是为什么我要向下滚动到iframe中
1条答案
按热度按时间4xrmg8kj1#
不需要切换。可以尝试以下代码吗: