当浏览器中有多个 windows 使用 python selenium 滚动条时如何向下滚动
How do I scroll down when there are multiple windows within a browser that has scroll bars using python selenium
所以点击一个按钮后弹出window(图中)弹出,它有2个带滚动条的元素。我想在主要的右侧元素上向下滚动。
browser.execute_script("window.scrollBy(0, 10000)","")
这行代码不起作用。它没有抛出错误,但没有效果。
这是滚动和对每一行执行操作的逻辑。
driver.find_element_by_xpath("(//div[@clas='pagec_list_wrapper]/div[@class='pagelist_item])[last()]").location_once_scrolled_into_view
time.sleep(2)
driver.find_element_by_xpath("(//div[@clas='pagec_list_wrapper]/div[@class='pagelist_item])[last()]").location_once_scrolled_into_view
# get the number of rows
rows = driver.find_elements_by_xpath("//div[@clas='pagec_list_wrapper]/div[@class='pagelist_item]")
# now you can access each row here in for loop
for rowNumber in range(len(rows)):
# scroll to the row
driver.find_element_by_xpath("(//div[@clas='pagec_list_wrapper]/div[@class='pagelist_item])[" + str(rowNumber+1) "]").location_once_scrolled_into_view
# if you want to click on the button (+) for that user
driver.find_element_by_xpath("((//div[@clas='pagec_list_wrapper]/div[@class='pagelist_item])[" + str(rowNumber+1) "]//span[@class='ui_button_icon'])[1]").click()
# you can use row element for any action with in the row
row.xxxxxx
所以点击一个按钮后弹出window(图中)弹出,它有2个带滚动条的元素。我想在主要的右侧元素上向下滚动。
browser.execute_script("window.scrollBy(0, 10000)","")
这行代码不起作用。它没有抛出错误,但没有效果。
这是滚动和对每一行执行操作的逻辑。
driver.find_element_by_xpath("(//div[@clas='pagec_list_wrapper]/div[@class='pagelist_item])[last()]").location_once_scrolled_into_view
time.sleep(2)
driver.find_element_by_xpath("(//div[@clas='pagec_list_wrapper]/div[@class='pagelist_item])[last()]").location_once_scrolled_into_view
# get the number of rows
rows = driver.find_elements_by_xpath("//div[@clas='pagec_list_wrapper]/div[@class='pagelist_item]")
# now you can access each row here in for loop
for rowNumber in range(len(rows)):
# scroll to the row
driver.find_element_by_xpath("(//div[@clas='pagec_list_wrapper]/div[@class='pagelist_item])[" + str(rowNumber+1) "]").location_once_scrolled_into_view
# if you want to click on the button (+) for that user
driver.find_element_by_xpath("((//div[@clas='pagec_list_wrapper]/div[@class='pagelist_item])[" + str(rowNumber+1) "]//span[@class='ui_button_icon'])[1]").click()
# you can use row element for any action with in the row
row.xxxxxx