• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Ardesco/Selenium-Maven-Template: A maven template for Selenium that will let you ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

Ardesco/Selenium-Maven-Template

开源软件地址(OpenSource Url):

https://github.com/Ardesco/Selenium-Maven-Template

开源编程语言(OpenSource Language):

Java 100.0%

开源软件介绍(OpenSource Introduction):

Selenium-Maven-Template

Join the chat at https://gitter.im/Ardesco/Selenium-Maven-Template

A maven template for Selenium 4 that has the latest dependencies so that you can just check out and start writing tests in four easy steps. If you like what you see have a look at my Selenium book Mastering Selenium Webdriver.

  1. Open a terminal window/command prompt
  2. Clone this project.
  3. cd Selenium-Maven-Template (Or whatever folder you cloned it into)
  4. mvn clean verify

All dependencies should now be downloaded and the example google cheese test will have run successfully in headless mode (Assuming you have Firefox installed in the default location)

What should I know?

  • To run any unit tests that test your Selenium framework you just need to ensure that all unit test file names end, or start with "test" and they will be run as part of the build.
  • The maven failsafe plugin has been used to create a profile with the id "selenium-tests". This is active by default, but if you want to perform a build without running your selenium tests you can disable it using:
mvn clean verify -P-selenium-tests
  • The maven-failsafe-plugin will pick up any files that end in IT by default. You can customise this is you would prefer to use a custom identifier for your Selenium tests.

Known problems...

  • It looks like SafariDriver is no longer playing nicely and we are waiting on Apple to fix it... Running safari driver locally in server mode and connecting to it like a grid seems to be the workaround.

Anything else?

Yes you can specify which browser to use by using one of the following on the command line:

  • -Dbrowser=firefox
  • -Dbrowser=chrome
  • -Dbrowser=ie
  • -Dbrowser=edge
  • -Dbrowser=opera
  • -Dbrowser=brave

If you want to toggle the use of chrome or firefox in headless mode set the headless flag (by default the headless flag is set to true)

  • -Dheadless=true
  • -Dheadless=false

You don't need to worry about downloading the IEDriverServer, EdgeDriver, ChromeDriver , OperaChromiumDriver, or GeckoDriver binaries, this project will do that for you automatically.

You can specify a grid to connect to where you can choose your browser, browser version and platform:

  • -Dremote=true
  • -DseleniumGridURL=http://{username}:{accessKey}@ondemand.saucelabs.com:80/wd/hub
  • -Dplatform=xp
  • -Dbrowser=firefox
  • -DbrowserVersion=44

You can even specify multiple threads (you can do it on a grid as well!):

  • -Dthreads=2

You can also specify a proxy to use

  • -DproxyEnabled=true
  • -DproxyHost=localhost
  • -DproxyPort=8080
  • -DproxyUsername=fred
  • -DproxyPassword=Password123

If the tests fail screenshots will be saved in ${project.basedir}/target/screenshots

If you need to force a binary overwrite you can do:

  • -Doverwrite.binaries=true

It's not working!!!

You have probably got outdated driver binaries, by default they are not overwritten if they already exist to speed things up. You have two options:

  • mvn clean verify -Doverwrite.binaries=true
  • Delete the selenium_standalone_binaries folder in your resources directory

Brave fails when in headless mode

Currently, Brave seems to be a bit flaky when running in headless mode, I would suggest running with -Dheadless=false

It's looking for the Brave binary in the wrong location

You probably don't have the brave binary installed in one of the default locations that this codebase is expecting. That's OK though, you can specify it by seeting the following system property:

  • -DbraveBinaryLocation=/path/to/brave-browser



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap