Tag: selenium

如何使docker日志在Java中

我想使用docker java客户端来创build和运行docker。 我想运行这样的东西: docker logs -f selenium-hub 如何在docker-java客户端上实现这个命令? 这是我的代码到目前为止: result = dockerClient.logContainerCmd(container.getId()) .withStdErr(true) .withStdOut(true) .withFollowStream(true) .withTailAll() .exec(logContainerResultCallback); try { logContainerResultCallback.awaitCompletion(); } catch (InterruptedException e) { throw new BaseException(e.getMessage()); }catch (Exception e){ throw new BaseException(e.getMessage()); } break; 为什么它不显示像docker表演? docker表演喜欢 "host": null, "port": 4444, "prioritizer": null, "capabilityMatcher": "org.openqa.grid.internal.utils.DefaultCapabilityMatcher" "throwOnCapabilityNotPresent": true, "newSessionWaitTimeout": -1, "jettyMaxThreads": -1, "nodePolling": 5000, "cleanUpCycle": […]

在完成构build之前构build发现已死亡的容器。 构build容器因为内存不足而死亡,或者Docker镜像缺lessglibc

我正在尝试在AWS中进行一些基本的Python Seleniumtesting。 我的想法是让CodeBuild运行它们,然后部署…很基本,对吧? 不过,使用aws/codebuild/python:2.7.12等AWS提供的映像,xvfb遇到了很多问题aws/codebuild/python:2.7.12 所以我决定使用一个Docker镜像,Selenium上的好人做的: https : //github.com/SeleniumHQ/docker-selenium/tree/master/StandaloneFirefox 我遇到了题目中的问题,我相当肯定这不是因为内存太less(我试过3GB和7GB)。 我也试过扩展Selenium docker文件以确保glibc安装完成: FROM selenium/standalone-firefox:latest RUN sudo apt-get -y update && sudo apt-get install -y build-essential 任何想法的问题是?

带有Phantomjs save_screenshot的Selenium webdriver在Docker容器中不起作用

代码在我的本地机器上工作,但不能在Docker容器中工作。 在我的本地机器上,它保存了所需网站的图像。 在Docker容器中,它使用正确的名称保存.png文件,但图像只有8kB,并且是空白的。 没有错误信息。 Docker容器可以访问因特网,因为从容器的bash pinging google.com显示Internet连接正在工作。 同样,如果我试图让它显示从这个页面的HTML,它在Docker中失败,但在我的本地系统上成功。 任何想法这里有什么问题? 这是调用Selenium和phantomjs的代码: def init_driver(): driver = webdriver.PhantomJS() driver.set_window_size(1600, 1200) # must give the page enough time to fully render driver.implicitly_wait(WAIT_TIME) return driver def render_page(driver, url): driver.get(url) def save_image(driver, path): driver.save_screenshot(path) IMAGE_NAME = 'test_image.png' WAIT_TIME = 10 url = 'https://www.google.com/' driver = phantom_tools.init_driver() render_page(driver, url) save_image(driver, IMAGE_NAME)

Selenium服务器在MacOS上与Docker协同工作,但不在Jenkins上

我有一个与Docker一起使用的Selenium服务器镜像,作为我们testing过程的一部分: FROM selenium/standalone-firefox:3.4.0-chromium 这在MacOS本地工作,但是当我在Jenkins(linux-gnu)上运行这个Docker容器时,Selenium似乎不工作。 我唯一的猜测是只有一个无头浏览器可以在Jenkins上工作。 有谁知道我能做些什么来运行Selenium的无头浏览器? 我不知道这是否有道理…但我想弄清楚为什么requests to Selenium server completely timeout on Jenkins ,而且我相信因为准系统Linux不能运行非无头浏览器。

seleniumtesting在当地工作,但不在Gitlab CI中

我目前正在开发一个涉及经典后端/前端架构的Java Spring Boot项目。 我正在尝试使用Selenium WebDriver来编写一些基本的集成testing。 问题是我写的testing在我的本地开发机器上没有任何问题,但通过持续集成设置(Gitlab CI)运行时没有通过。 示例testing的代码如下: @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @ActiveProfiles("test") public class ExampleTest { @LocalServerPort private int port; WebDriver wd; @Test public void successfulLogin(){ String url = "http://localhost:" + port; wd = new HtmlUnitDriver(); wd.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS); wd.get(url); } } 相对的gitlab-ci.yml部分是: stages: – test maven-test: image: maven:3.5.0-jdk-8 stage: test script: "mvn test -B […]

如何运行无头selenium脚本,独立于主机和浏览器

我想在一个CI作业上运行一个以Java为基础的无脚本selenium“脚本”,与主机(和浏览器)无关。 我可以构build一个jar并在terminal上运行“脚本”,我只需要非常小心地指向和configuration正确的驱动程序,具体取决于我运行该脚本的主机的操作系统和浏览器。 但是,在CI主机上,我不一定会控制主机和浏览器,如果它们可用的话。 所以我想让脚本的执行独立于脚本运行的主机和浏览器。 它可以运行在Jenkins,Travis,Gitlab CI等的奴隶实例上。 以前有几个问题是针对给定的主机和浏览器组合的。 我可以把主机拿出来,让浏览器可用,例如,通过一个容器。 如果浏览器可用作容器图像,则可以针对不同的浏览器运行脚本,每个浏览器都有自己的图像。 而且我已经准备好适合这些浏览器实例的驱动程序了。 这是可行的,我可以做到这一点最简单的方法是什么?

如何使用代理运行selenium铬节点?

我使用Docker Selenium映像运行浏览器节点,repo可以在这里https://github.com/SeleniumHQ/docker-selenium 。 没有关于如何使用config.json来提供代理值的文档。 我使用Selenium版本2.44.0。 在我的基础架构中,某些资源来源于需要在浏览器上进行代理configuration才能访问的位置。 我正在尝试在chrome节点上设置代理。 根据这里的文档 ,代理可以设置如下: java -jar selenium-2.44.0.jar -Dhttp.proxyHost=192.168.2.10 -Dhttp.proxyPort=80 我的代理不需要使用用户名和密码,因此我忽略了这些值。 SeleniumHQ文档中没有明确提到的是,无论是在集线器还是节点上,还是仅在节点上,都需要代理configuration。 我尝试了不同的组合,但没有为我工作。 我正在运行的实际命令是: 对于Hub: java -jar /opt/selenium/selenium-server-standalone.jar -role hub -Dhttp.proxyHost=192.168.2.10 -Dhttp.proxyPort=80 -hubConfig /opt/selenium/hubconfig.json 当我运行上面的命令,我可以看到-D *值显示在控制台configuration。 对于节点: xvfb-run –server-args=":99.0 -screen 0 1360x1020x24 -ac +extension RANDR" java -jar /opt/selenium/selenium-server-standalone.jar -Dhttp.proxyHost=192.168.2.10 -Dhttp.proxyPort=80 -role node -hub http://$HUB_PORT_4444_TCP_ADDR:$HUB_PORT_4444_TCP_PORT/grid/register -nodeConfig /opt/selenium/config.json 当我运行这个命令时,我可以再次在控制台上看到代理值,但是我的资源没有被浏览器加载。 另外,在一个侧面说明,这似乎可以在开发人员方面( 在Java代码 )完成,但我很想在我的(操作)方面解决它。

验收testing,docker和selenium

我尝试创build一些旨在build立我的JavaScript应用程序的容器。 以下是我需要做的事情: 安装我的依赖关系 开始我的unit testing build立我的项目 开始我的验收testing 这是我的项目dockerfile: FROM node:6.9 # Enviroment variables ENV HOMEDIR /data RUN mkdir -p ${HOMEDIR} WORKDIR ${HOMEDIR} # install all dependencies ADD package.json ./ RUN npm install # add node content initially ADD . . CMD CI=true npm test && npm run build && npm run test:acceptance 事实是,当我开始我的验收testing时,我需要使用selenium服务器和phantomjs浏览器。 这样,感谢stackoverflow社区,我创build了一个docker-compose.yml文件,如下所示: version: […]

在Docker容器中执行Firefox浏览器进行Seleniumtesting

我有一个Java应用程序,它通过Selenium WebDriver Libraray控制FF浏览器中的自动GUItesting。 Java应用程序从数据库读取testing用例,并根据代码逻辑执行testing用例。 例如,如果应用程序读入一个字段,它将使用Selenium框架中的“findElement”方法进行search。 我不使用任何testing脚本Selenium。 目前这发生在员工的本地工作站上。 现在我想将整个环境转移到Docker容器中。 甚至有可能在容器中实例化Firefox浏览器? 顺便说一句:我不需要看到我的浏览器的实际GUI。 其次: dockerhub上有几个容器可以使用selenium,但这些不适合我的环境,我是对的吗? 据我所知SeleniumGrid期待testscripts,不能通过运行时执行。 我用Vagrant打开了一个Linux VM(Debian:Jessie发行版),然后运行Docker。 我还是Docker的初学者。 我在这里找不到任何有关我的目的的问题。 提前致谢!

无法在容器中启动seleniumtesting,WebDriverException:Chrome无法启动:exception退出

我的问题是 – 我不能启动容器内的seleniumtesting。 我的docker文件看起来像: FROM selenium/node-chrome EXPOSE 9090 USER root RUN mkdir /code WORKDIR /code ADD requirements_tests.txt /code/ RUN apt-get update RUN apt-get install -y python python-dev python-distribute python-pip RUN pip install -r requirements_tests.txt ADD /selenium_tests HTMLTestRunner.py launch_selenium_tests.py chromedriver /code/ /selenium_tests包含我所有的testing, launch_selenium_tests.py – 它是我的testing启动器。 import time from pyvirtualdisplay import Display import os class SeleniumTestCase(unittest.TestCase): def […]