selenium在windows下运行正常然而在Linux下报错,元素未找到

import time

from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.chrome.options import Options


def sign_in():
    opt = Options()
    opt.headless = True
    opt.add_argument('--no-sandbox')
    opt.add_argument('--disable-dev-shm-usage')
    opt.add_argument('--headless')
    opt.add_argument('blink-settings=imagesEnabled=false')
    opt.add_argument('--disable-gpu')
    chrome = webdriver.Chrome(options=opt)
    chrome.get("http://my.lzu.edu.cn:8080/login?service=http://my.lzu.edu.cn")
    chrome.find_element_by_id("username").send_keys("****")
    chrome.find_element_by_id("password").send_keys("********")
    chrome.find_element_by_class_name("g-recaptcha").click()
    time.sleep(3)
    s = chrome.find_element_by_xpath("/html/body/div[1]/div[2]/div[2]/div[1]/div[1]/div[2]/ul/li[1]/a/div[2]")
    ActionChains(chrome).move_to_element(s).perform()
    time.sleep(3)
    chrome.find_element_by_xpath(
        "/html/body/div[1]/div[2]/div[2]/div[1]/div[1]/div[2]/ul/li[1]/a/div[2]/p[2]/span[1]").click()
    time.sleep(3)
    iframe = chrome.find_element_by_xpath('//*[@id="iframe"]')
    chrome.switch_to.frame(iframe)
    try:
        chrome.find_element_by_class_name("uni-modal__btn.uni-modal__btn_primary").click()
        time.sleep(1)

        chrome.find_element_by_class_name("cu-btn.block.bg-blue.margin-tb-sm.lg").click()
    except Exception:
        chrome.find_element_by_class_name("cu-btn.block.bg-blue.margin-tb-sm.lg").click()
    time.sleep(5)
    chrome.close()


sign_in()

代码是测试的功能,故写的不算规范,但在windows下顺利运行完成,但在Linux报如下错误:

萌新求教。。

建议百度参考:https://blog.csdn.net/wushuai150831/article/details/78648228

我这两天也碰到这个问题了,你的解决了吗?