Issue running Selenium IDE test suite using Selenium Standalone server

倖福魔咒の 提交于 2019-12-04 14:48:14

Since this question got much attention and needed a proper solution, which I found this way:

First of all we need proper addons to setup headless tests

Getting the right addons

I am already using following selenium IDE addons

  1. datadriven v0.2
  2. flowcontrol v08
  3. includecommand 1.3

What I need is respective selenium addons which work with selenium core server for which I need

  1. datadriven_v0.2-core.js
  2. flowcontrol ( goto_sel08.js)
  3. includecommand ( includeCommand_2.3.js) origional source

    since openqa.org does not maintain these addons anymore (probably broken or so) You have to use wayback machine to get js files ( no luck with zip attachments). e g flowcontrol in wayback machine

Since I have done this already and created a gist with some fixes

  1. datadriven_v0.2-core.js
  2. flowcontrol ( goto_sel08.js)
  3. includeCommand_2.3.js
  4. user-extension.js ( all three of above combined)

Setting up Headless Tests

a) install xvfb ( X Vritual Frame Buffer and firefox )

sudo apt-get update && sudo apt-get install -y xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic xvfb x11-apps  firefox

b) create xvfb init script /var/init.d/xvfb

if [ -z "$1" ]; then
  echo "`basename $0` {start|stop}"
  exit
fi

case "$1" in
start)
  /usr/bin/Xvfb :99 -ac -screen 0 1024x768x8 &
;;
stop)
  killall Xvfb
;;
esac

c) add to startup script:

sudo update-rc.d xvfb defaults
sudo chmod +x /etc/init.d/xvfb

d) start the xvfb

/etc/init.d/xvfb start

e) Setup selenium Tests (you can put test anywhere)

sudo mkdir /usr/local/SeleniumTests   && cd /usr/local/SeleniumTests

checkout/copy your html tests to /usr/local/SeleniumTests

f) create alias to test directory (config file 'selenium_alias') (only allow from localhost)

<IfModule alias_module>
       Alias  /SeleniumTests/  /usr/local/SeleniumTests/
  </IfModule>
  <Directory "/usr/local/SeleniumTests/">
       Options Indexes MultiViews FollowSymLinks
       AllowOverride None
       Order deny,allow
       Deny from all
       Allow from 127.0.0.1
   </Directory>

sudo mv SeleniumTests/selenium_alias /etc/apache2/sites-avaiable
sudo a2ensite selenium
sudo service apache2 restart

g) update selenium tests data (/usr/local/SeleniumTests/tests/data) e.g change test username/password and baseUrl to test app (which I have in xml file)

h) Download Seleninum Server jar file

sudo mkdir /var/lib/selenium/ 
sudo wget http://selenium.googlecode.com/files/selenium-server-standalone-2.39.0.jar -o /var/lib/selenium/selenium-server.jar

i) Run the headless /Selenese Tests

export DISPLAY=":99" && java -jar /var/lib/selenium/selenium-server.jar   -htmlSuite *firefox https://localhost "/usr/local/SeleniumTests/tests/my_app_smoke_testing_suite.html" "firefox-results.html" -trustAllSSLCertificates  -ensureCleanSession -port 5561 -userExtensions /usr/local/SeleniumTests/addons/user-extensions.js

Note I have my selenium addons setup under /usr/local/SeleniumTests/addons

Some of the the steps might not be desirable in all situations.

Try this:

  <Selenium server location path>java -jar <selenium-server name>.jar –htmlSuite "*<browser_name>" "<Url of base website>" "<Path of html_suite>" "<Path to store reports>"

selenium-server name :- selenium-server-standalone-2.xx.xx was used.

browser_name :- "iexplore" for Internet Explorer/ "firefox" for Mozilla Firefox

Url of base website :- Base URL.

Path of html_suite :- The path of test suite you used to save file (E.g.:"C:\TestSuite.htm", assuming "C" drive as location you used to save test suite).

Path to store reports :-The path you want to save your test result into (E.g.:"C:\TestResult.htm", assuming "C" drive as location you used to save test result).

Some commands are not working in Firefox:

The user extension goto_sel_ide that defines the While and Goto commands does not work with Selenium RC. Include the user extension goto_sel08.js instead.

From: https://wiki.mozilla.org/Running_IDE_scripts_with_Selenium_RC

I think you are following these steps from this page:

  1. Download goto_sel08.js
  2. Download the 1.3 version of the includeCommand4IDE extension.
  3. Download the most recent version (0.2) of the datadriven.js extension.
  4. Merged these files to new user-extensions.js file. This order is critical!
  5. create an xml file which must contain all the data–input and output–for a single test case.
  6. Utilize your .xml file
  7. Use Selenium-IDE or an editor to create an HTML test suite that includes your data-driven test as one of the tests to be executed.
  8. Execute a command line:

-jar selenium-server.jar

    -userExtensions user-extensions.js
    -htmlSuite 
       "*chrome" 
       "`<base URL>`" 
       "`<Selenium test suite file>`" 
       "`<results log file>`"  
   -timeout nnnn

I don't post all steps. I think these steps are important for create data-driven testing from a Selenium-RC command line. Please check all steps!

Perhaps its working on Ubuntu OS, if its works on Windows. Two popup window is weird for me, but may be not is problem. I can only offer check these points:

  • create suite.html with firefox selenium IDE
  • try to use *chrome in command line.
  • Please check order of scripts in user-extensions.js file.

I hope it helps!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!