How to get browser name using Selenium WebDriver with Java?

前端 未结 5 959
情深已故
情深已故 2020-12-31 09:50

I have a test case and need to execute based on the browser name i.e. IE or Chrome. In this test case some part will depend on browser type.

How will I get the brows

5条回答
  •  悲哀的现实
    2020-12-31 09:59

    You're the tester, so it's up to you to write code/scripts to explicitly test each of the various browser/version combinations and their various nuances and subtleties (whilst trying to reuse as much logic as you can, minimise duplication etc.)

    The nature of WebDriver is that you, the tester, are doing the driving - not the browser. Don't try to detect things.

    So given that you have different behaviour for IE and for Chrome, you should explicitly create a WebDriver instance for each (in different @Tests) and set up the required data (likewise properties, Capabilities etc.) as appropriate.

    By all means share common lookup code between the tests, but until your tests are robust and working you shouldn't try to refactor them.

提交回复
热议问题