Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Selenium处理内部滚动-如何在div内滚动_Python_Selenium Webdriver_Pytest - Fatal编程技术网

Python Selenium处理内部滚动-如何在div内滚动

Python Selenium处理内部滚动-如何在div内滚动,python,selenium-webdriver,pytest,Python,Selenium Webdriver,Pytest,这是我的网站要测试: 在网站的(RHS)分数部分,我想滚动到最上面的卡片 我尝试使用了scrollIntoView()和moveToElement操作: top_card=driver.find_element_by_xpath( "(// div[@class ='si-matBox si-matchBlock si-link-active si-format-t20 si-matCompleted si-cricket'])[1]")

这是我的网站要测试:

在网站的(RHS)分数部分,我想滚动到最上面的卡片

我尝试使用了
scrollIntoView()
moveToElement
操作:

top_card=driver.find_element_by_xpath(
            "(// div[@class ='si-matBox si-matchBlock si-link-active si-format-t20 si-matCompleted si-cricket'])[1]")  
      
actions.move_to_element(top_card).perform()
top_card.click()
这是:

main_div = driver.find_elements_by_xpath(""//div[@class='si-fixCntnr si-fix-widget']"") 

for list in main_div :
    driver.execute_script("arguments[0].scrollIntoView();", top_card )
它们似乎都不起作用。
我是否正确使用了这些动作?或者有没有其他方法来选择最上面的卡片