selenium IDE - change Base URL for all tests?

2019-07-04 23:45发布

I have a suite of 15 test cases.

I now want to run them against a different Base URL.

Is there any way to change all 15 in one go?

So far what I have had to do is change each of them one-by-one which is slow and tedious.

6条回答
The star\"
2楼-- · 2019-07-05 00:20

You can create a properties file.

In this properties file you declare a URL variable.
You can then get this variable through this properties file to set the url base.

查看更多
聊天终结者
3楼-- · 2019-07-05 00:29

More experience has turned up the following:

Yes you can (and should) remove the HEAD references as amey indicated.

However you will find the behaviour extremely confusing because:

  • When you change the Base URL to something new you frequently need to exit and re-enter Selenium in order for that to always be applied to all the other cases.

  • If you change the Base URL for a case that isn't the first Test Case you will likely have problems. Addres this for now by changing the Base URL for the first Test Case in the suite, save the suite, exit Selenium and re-enter.

There's clearly some bugs in Selenium that make changing the Base URL vcery confusing but once you know the pitfalls to avoid you can make the changes successfully.

查看更多
劫难
4楼-- · 2019-07-05 00:31

Our selenium tests are executed automatically by the CI-tool with a command like: java -jar selenium-server-standalone-2.46.0.jar -htmlSuite "*firefox" "$SITE_URL" "$BUILD_PATH/$TEST_PATH" "$ARTIFACTS_PATH/selenium-results.html" where

  • $SITE_URL - the URL to the site being tested, effectively this value is a base url
  • $BUILD_PATH/$TEST_PATH - the path to the test suite
  • $ARTIFACTS_PATH/selenium-results.html - the path to test results, i.e. the results of selenium run.

At the same time none of our tests contains <link rel="selenium.base" href="http://www.example.com/" />, to achieve the same - remove it from existing tests and remove it from selenium IDE template:

  1. Open Selenium IDE
  2. Go to Options -> Options
  3. Find Formats tab
  4. Find a textarea named "Template for new test html file" and remove the <link rel="selenium.base" ... line from there.
查看更多
Bombasti
5楼-- · 2019-07-05 00:37

Since none of the solutions mentioned it, here is my solution.

  1. Download BK ReplaceEM

  2. For each Selenium IDE file replace the following:

from:

link rel="selenium.base" href="<OLD URL BASE>" to: link rel="selenium.base" href="<NEW URL BASE>"

查看更多
闹够了就滚
6楼-- · 2019-07-05 00:43

Try this method and changing URLs should not be an issue - http://greenlanternautomationframework.blogspot.com/p/selenium-ide.html We are constantly using environments QA1 or QA2 or localhost and all that jazz. So, it helps to make all the test cases independent of the URL and then add a URL. Check out the whole tutorial for a clear picture or Skip to section - 04_GoToURL

查看更多
Evening l夕情丶
7楼-- · 2019-07-05 00:44

You can open all the test case xmls in a text editor. You can even just edit the 'source' in the selenium IDE (see screenshot below). Just remove the <link rel="selenium.base" href="http://dmstaff2.herokuapp.com/" /> in each test case and then they will use the url of whatever your firefox web browser has at that point.

[Edit - please note my answer for important info about doing this! Michael(OP)]

enter image description here

查看更多
登录 后发表回答