python+selenium自动化测试-17解决.click()无法展开二级菜单的问题

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/qq_24601279/article/details/102775071

在测试过程中,有时候发现使用.click()无法展开二级菜单,遇到这个问题的时候,不妨可以试试模拟键盘的操作,用.send_keys(Keys.ENTER)可以解决这个问题,如果还是不可以,请注意检查是不是网络差或者服务器响应缓慢导致元素加载不完全的情况。

from selenium.webdriver.common.keys import Keys

    def type_openGoodList(self):
        try:
            sleep(2)
self.find_element(*self.taskMan6_loc).send_keys(Keys.ENTER)  # 展开二级菜单
            self.find_element(*self.goodList_loc).click()  #
        except BaseException as msg:
            print(msg)

猜你喜欢

转载自blog.csdn.net/qq_24601279/article/details/102775071