在 Cucumber Ruby 中使用 Selenium ChromeDriver 在 W3C 模式(Selenium::WebDriver::Error::UnknownCommandError)下无法调用非 W3C 标准命令 [英] Cannot call non W3C standard command while in W3C mode (Selenium::WebDriver::Error::UnknownCommandError) with Selenium ChromeDriver in Cucumber Ruby

查看:36
本文介绍了在 Cucumber Ruby 中使用 Selenium ChromeDriver 在 W3C 模式(Selenium::WebDriver::Error::UnknownCommandError)下无法调用非 W3C 标准命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有 Cucumber Ruby 自动化框架,我们在 Jenkins 上的 Docker 中的 Chrome 无头浏览器上运行了一些测试.几天前,我们开始收到错误消息此版本的 ChromeDriver 仅支持 Chrome 版本 75",这次我们使用的是 ChromeDriver 2.46 和 google-chrome-unstable 浏览器,使用以下命令:

We have Cucumber Ruby automation framework where we run few tests on Chrome headless browser in a Docker on Jenkins. A few days ago we started receiving an error "This version of ChromeDriver only supports Chrome version 75" this time we were using ChromeDriver 2.46 and with google-chrome-unstable browser using the following command:

#Chrome
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list
RUN apt-get update -y
RUN apt-get install -y google-chrome-unstable
RUN apt-get install unzip

# Set up Chromedriver Environment variables
ENV CHROMEDRIVER_VERSION 2.46
ENV CHROMEDRIVER_VERSION 75.0.3770.8
ENV CHROMEDRIVER_DIR /chromedriver
RUN mkdir $CHROMEDRIVER_DIR
# Download and install Chromedriver
RUN wget -q --continue -P $CHROMEDRIVER_DIR "http://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VERSION/chromedriver_linux64.zip"
RUN unzip $CHROMEDRIVER_DIR/chromedriver* -d $CHROMEDRIVER_DIR
ENV PATH $CHROMEDRIVER_DIR:$PATH

我现在已将 chromedriver 版本更新为 75.0.3770.8,并将浏览器更新为 google-chrome-beta=75.0.3770.27-1

I have now updated chromedriver version to 75.0.3770.8 and browser to google-chrome-beta=75.0.3770.27-1

#Chrome
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list
RUN apt-get update -y
RUN apt-get install -y google-chrome-beta=75.0.3770.27-1
RUN apt-get install unzip

# Set up Chromedriver Environment variables
ENV CHROMEDRIVER_VERSION 75.0.3770.8
ENV CHROMEDRIVER_DIR /chromedriver
RUN mkdir $CHROMEDRIVER_DIR
RUN echo $CHROMEDRIVER_DIR
# Download and install Chromedriver
RUN wget -q --continue -P $CHROMEDRIVER_DIR "http://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VERSION/chromedriver_linux64.zip"
RUN unzip $CHROMEDRIVER_DIR/chromedriver* -d $CHROMEDRIVER_DIR
ENV PATH $CHROMEDRIVER_DIR:$PATH

现在我可以看到错误:

unknown command: 在 W3C 模式下无法调用非 W3C 标准命令 (Selenium::WebDriver::Error::UnknownCommandError)

是否可以禁用 W3C 模式或下载不使用它的旧版 Chrome 浏览器和驱动程序?我认为禁用 W3C 检查的可能性会很大.

Is it possible to disable W3C mode or download an older version of Chrome browser and driver that doesn't use it? I think the possibility to disable W3C check would be great.

推荐答案

你所要做的只是在初始化 webdriver 时禁用 W3C

All you have to do is just to disable the W3C when initializing the webdriver

options = webdriver.ChromeOptions()
options.add_experimental_option('w3c', False)
create_webdriver('Chrome', options=options)

环境:

  • 铬 75
  • ChromeDriver 75

这篇关于在 Cucumber Ruby 中使用 Selenium ChromeDriver 在 W3C 模式(Selenium::WebDriver::Error::UnknownCommandError)下无法调用非 W3C 标准命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆