我有以下docker-container
class Order extends ActiveRecord
{
public function getItems()
{
return $this->hasMany(Item::className(), ['id' => 'item_id'])
->viaTable('order_item', ['order_id' => 'id']);
}
}
or alternatively,
class Order extends ActiveRecord
{
public function getOrderItems()
{
return $this->hasMany(OrderItem::className(), ['order_id' => 'id']);
}
public function getItems()
{
return $this->hasMany(Item::className(), ['id' => 'item_id'])
->via('orderItems');
}
}
我与之合作:
FROM ubuntu:xenial
MAINTAINER Hasan Kara
RUN set -xe \
\
# Install Java, Chrome, Xvfb, and unzip
&& apt-get update \
&& apt-get install -y \
openjdk-8-jre \
chromium-browser \
xvfb \
curl \
wget \
unzip \
&& rm -rf /var/lib/apt/lists/* \
&& ln -s /usr/lib/chromium-browser/chromium-browser /usr/bin/google-chrome \
\
# Download and install chrome drive and selenium server standalone
&& wget -q "https://chromedriver.storage.googleapis.com/2.27/chromedriver_linux64.zip" \
&& wget -q "http://selenium-release.storage.googleapis.com/3.0/selenium-server-standalone-3.0.1.jar" \
&& unzip chromedriver_linux64.zip \
&& mv chromedriver /usr/local/bin \
&& mv selenium-server-standalone-3.0.1.jar /usr/local/bin
VOLUME /downloads
ENV DISPLAY :10
CMD export DISPLAY=:10 && Xvfb :10 -screen 0 1366x768x24 -ac & google-chrome --no-sandbox -remote-debugging-port=9222 & java -jar /usr/local/bin/selenium-server-standalone-3.0.1.jar &
EXPOSE 4444 9222
在bash中我手动运行,因为由于某种原因CMD不起作用......
docker run --rm -it --shm-size=512m --name chromium -p 4444:4444 -p 9222:9222 hasankarafhnw/seleniumchromium /bin/bash
现在我可以在“http://192.168.99.100:4444/wd/hub/static/resource/hub.html”处完美连接到selenium hub,但如果尝试:
我收到以下错误:
仅允许本地连接。 信息 - 尝试双方言 会议,假设Postel的定律适用于远程端
INFO - 执行:[截屏])WARN - 抛出异常 org.openqa.selenium.NoSuchSessionException:没有这样的会话
Chromedriver:2.27.440175
铬:55.0.2883.87
Selenium-server-standalone:3.0.1
Docker:1.13
主机操作系统:赢7
RemoteDriveCode:
export DISPLAY=:10 && Xvfb :10 -screen 0 1366x768x24 -ac & google-chrome --no-sandbox -remote-debugging-port=9222 & java -jar /usr/local/bin/selenium-server-standalone-3.0.1.jar &
答案 0 :(得分:0)
我刚使用了官方的selenium docker图片:
https://hub.docker.com/r/selenium/standalone-chrome/
答案 1 :(得分:0)
您需要为chromedriver可执行文件(不是chrome!)设置whitelisted-ips参数。您可以在节点启动时通过设置系统属性webdriver.chrome.whitelistedIps
来实现它,就像在命令中一样:
CMD export DISPLAY=:10 && Xvfb :10 -screen 0 1366x768x24 -ac & google-chrome --no-sandbox -remote-debugging-port=9222 & java -Dwebdriver.chrome.whitelistedIps= -jar /usr/local/bin/selenium-server-standalone-3.0.1.jar &