在 W3C 模式下(Selenium::WebDriver::Error::UnknownCommandError)无法在 Cucumber Ruby 中使用 Selenium ChromeDriver 调用非 W3C 标准命令 [英] Cannot call non W3C standard command while in W3C mode (Selenium::WebDriver::Error::UnknownCommandError) with Selenium ChromeDriver in Cucumber Ruby
问题描述
我们有 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
现在我可以看到错误:
未知命令:在 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
这篇关于在 W3C 模式下(Selenium::WebDriver::Error::UnknownCommandError)无法在 Cucumber Ruby 中使用 Selenium ChromeDriver 调用非 W3C 标准命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!