tag:blogger.com,1999:blog-68985341500069099392024-02-19T19:46:19.265+11:00QA BlogUnknownnoreply@blogger.comBlogger62125tag:blogger.com,1999:blog-6898534150006909939.post-27065349048570078832019-02-24T21:49:00.004+11:002019-02-24T21:49:59.408+11:00MAC - could not find aapt Please set the ANDROID_HOME environment variable with the Android SDK Root directory path
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #ca3323}
span.s1 {font-variant-ligatures: no-common-ligatures}
</style>
<br />
<div class="p1">
<span class="s1"><span style="color: black;">An unknown server-side error occurred while processing the command. Original error: Could not find aapt Please set the ANDROID_HOME environment variable with the Android SDK root directory path. (Selenium::WebDriver::Error::UnknownError)</span></span></div>
<div class="p1">
<span class="s1"><span style="color: black;"><span class="Apple-converted-space"> </span>UnknownError: An unknown server-side error occurred while processing the command. Original error: Could not find aapt Please set the ANDROID_HOME environment variable with the Android SDK root directory path.</span></span></div>
<div class="p1">
<span class="s1"><span style="color: black;"><span class="Apple-converted-space"> </span>at getResponseForW3CError (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-base-driver/lib/protocol/errors.js:826:9)</span></span></div>
<div class="p1">
<span class="s1"><span style="color: black;"><span class="Apple-converted-space"> </span>at asyncHandler (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-base-driver/lib/protocol/protocol.js:447:37)</span></span></div>
<div class="p1">
<span class="s1"><span style="color: black;"><span class="Apple-converted-space"> </span>at process._tickCallback (internal/process/next_tick.js:68:7)</span></span></div>
<div class="p1">
<span class="s1"><span style="color: black;"><span class="Apple-converted-space"> </span>./features/support/hooks.rb:2:in `Before'</span></span></div>
<div class="p1">
<span class="s1"><span style="color: black;"><br /></span></span></div>
<div class="p1">
<span class="s1"><span style="color: black;"><br /></span></span></div>
<div class="p1">
<span class="s1"><span style="color: black;">To fix the issue:</span></span></div>
<div class="p1">
<span class="s1"><span style="color: black;"><br /></span></span></div>
<div class="p1">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000}
span.s1 {font-variant-ligatures: no-common-ligatures}
</style>
</div>
<div class="p1">
<span class="s1">export ANDROID_HOME="/Users/Users_name/Library/Android/sdk/"</span></div>
<div class="p1">
<span class="s1"><br /></span></div>
<div class="p1">
<br /></div>
<br />Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6898534150006909939.post-36734312336075958402019-02-24T21:39:00.001+11:002019-02-24T21:39:37.048+11:00Appium - stack level too deep (SystemStackError)
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #ca3323}
span.s1 {font-variant-ligatures: no-common-ligatures}
</style>
<br />
<div class="p1">
<span class="s1">stack level too deep (SystemStackError)</span></div>
<div class="p1">
<span class="s1"><span class="Apple-converted-space"> </span>./features/step_definitions/Appium/appiumtest.rb:6:in </span></div>
<div class="p1">
<span class="s1"><span class="Apple-converted-space"> </span>appium/features/regression/appiumtest.feature:5:in </span></div>
<br /><br />
The error is caused because the system tries to find the element, but the it is not connected with the emulator and the appium server.<br />
<br />
To solve that add a hooks.rb file under the support directory to start and end the driver when the test runs:<br />
<br />
hooks.rb:<br />
<br />
Before do<br />
$driver.start_driver <br />
end<br />
<br />
After do<br />
$driver.driver_quit <br />
endUnknownnoreply@blogger.com0tag:blogger.com,1999:blog-6898534150006909939.post-25784583774792487492016-09-14T13:18:00.003+10:002016-09-14T13:18:59.276+10:00Remove RVM on OSX and switch to RBENV
<br />
<div class="p1">
<span class="s1">$ rvm implode</span></div>
<div class="p1">
<span class="s1">
</span></div>
<div class="p1">
<span class="s1">Psychologist intervened, cancelling implosion, crisis avoided :)</span></div>
<div class="p1">
<span class="s1"><br /></span></div>
<div class="p1">
$ rvm implode --force</div>
<div class="p1">
</div>
<div class="p1">
<span class="s1">Are you SURE you wish for rvm to implode?</span></div>
<div class="p1">
<span class="s1">
</span></div>
<div class="p1">
<span class="s1">$ This will recursively remove /home/local/.rvm and other rvm traces? yes</span></div>
<div class="p1">
<span class="s1"><br /></span></div>
<div class="p1">
<span class="s1">Exit and reopen the terminal</span></div>
<div class="p1">
<span class="s1"><br /></span></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6898534150006909939.post-18636918416997844752016-09-14T12:31:00.001+10:002016-09-14T12:41:07.834+10:00Update Ruby-Build definition in OSX <div class="p1">
<span class="s1">$ rbenv install 2.1.3</span></div>
<div class="p1">
<span class="s1">ruby-build: definition not found: 2.1.3</span></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1">You can list all available versions with `rbenv install --list'.</span></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1">If the version you're looking for is not present, first try upgrading</span></div>
<div class="p1">
<span class="s1">ruby-build. If it's still missing, open a request on the ruby-build</span></div>
<br />
<div class="p1">
<span class="s1">issue tracker: https://github.com/sstephenson/ruby-build/issues</span></div>
<div class="p1">
<span class="s1"><br /></span></div>
<div class="p1">
<span class="s1">$ sudo brew uninstall ruby-build</span></div>
<div class="p1">
<span class="s1">
</span></div>
<div class="p1">
<span class="s1">Uninstalling /usr/local/Cellar/ruby-build/20140702...</span></div>
<div class="p1">
<span class="s1"><br /></span>
<br />
<div class="p1">
<span class="s1">$ sudo brew install --HEAD ruby-build</span></div>
<div class="p2">
<span class="s2">==></span><span class="s1"> Cloning https://github.com/sstephenson/ruby-build.git</span></div>
<div class="p1">
<span class="s1">Cloning into '/Library/Caches/Homebrew/ruby-build--git'...</span></div>
<div class="p1">
<span class="s1">remote: Counting objects: 343, done.</span></div>
<div class="p1">
<span class="s1">remote: Compressing objects: 100% (276/276), done.</span></div>
<div class="p1">
<span class="s1">remote: Total 343 (delta 147), reused 154 (delta 63), pack-reused 0</span></div>
<div class="p1">
<span class="s1">Receiving objects: 100% (343/343), 88.76 KiB | 126.00 KiB/s, done.</span></div>
<div class="p1">
<span class="s1">Resolving deltas: 100% (147/147), done.</span></div>
<div class="p1">
<span class="s1">Checking connectivity... done.</span></div>
<div class="p2">
<span class="s2">==></span><span class="s1"> ./install.sh</span></div>
<br />
<div class="p1">
<span class="s1"><br /></span>
<div class="p1">
<span class="s1">$ rbenv install 2.1.3</span></div>
<div class="p1">
<span class="s1">Downloading ruby-2.1.3.tar.bz2...</span></div>
<span class="s1">
</span><br />
<div class="p1">
<span class="s1">-> https://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.3.tar.bz2</span></div>
</div>
<div class="p1">
<span class="s1"><br /></span></div>
<div class="p1">
<span class="s1"><br /></span></div>
</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6898534150006909939.post-60859487577745567002015-11-26T19:19:00.001+11:002015-11-26T19:19:20.184+11:00How to Output cucumber results in STDOUT or console and as a html report<br />
If you need to output the cucumber result both as a html report and to STDOUT you can use the -f rerun --out rerun.txt. This will be useful if you run the cucumber in jenkins where you want to see the html report as well as to follow the progress of your test.<br />
<br />
bundle exec cucumber -f pretty -f html --out report.html -f rerun --out rerun.txt features\regression\ --tag @testUnknownnoreply@blogger.com1tag:blogger.com,1999:blog-6898534150006909939.post-29833624265284143062015-11-21T17:25:00.000+11:002015-11-21T17:26:21.896+11:00How to Install Gem Debugger in Ruby <div class="p1">
<span class="s1">To install debugger -> try using 'gem install debugger2' instead of debugger. </span></div>
<div class="p1">
<span class="s1"><br /></span></div>
<div class="p1">
<span class="s1"><b>Before:</b></span></div>
<div class="p1">
<span class="s1">Installing debugger-ruby_core_source 1.3.8</span></div>
<div class="p2">
<span class="s1">/Users/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/ext/builder.rb:73: warning: Insecure world writable dir /usr/local in PATH, mode 040777</span></div>
<div class="p3">
<span class="s1"></span><br /></div>
<div class="p4">
<span class="s1">Gem::Ext::BuildError: ERROR: Failed to build gem native extension.</span></div>
<div class="p3">
<span class="s1"></span><br /></div>
<div class="p4">
<span class="s1"> /Users/.rbenv/versions/2.1.2/bin/ruby extconf.rb </span></div>
<div class="p4">
<span class="s1">*** extconf.rb failed ***</span></div>
<div class="p4">
<span class="s1">Could not create Makefile due to some reason, probably lack of necessary</span></div>
<div class="p4">
<span class="s1">libraries and/or headers. Check the mkmf.log file for more details. You may</span></div>
<div class="p4">
<span class="s1">need configuration options.</span></div>
<div class="p3">
<span class="s1"></span><br /></div>
<div class="p4">
<span class="s1">Provided configuration options:</span></div>
<div class="p4">
<span class="s1"><span class="Apple-tab-span"> </span>--with-opt-dir</span></div>
<div class="p4">
<span class="s1"><span class="Apple-tab-span"> </span>--without-opt-dir</span></div>
<div class="p4">
<span class="s1"><span class="Apple-tab-span"> </span>--with-opt-include</span></div>
<div class="p4">
<span class="s1"><span class="Apple-tab-span"> </span>--without-opt-include=${opt-dir}/include</span></div>
<div class="p4">
<span class="s1"><span class="Apple-tab-span"> </span>--with-opt-lib</span></div>
<div class="p4">
<span class="s1"><span class="Apple-tab-span"> </span>--without-opt-lib=${opt-dir}/lib</span></div>
<div class="p4">
<span class="s1"><span class="Apple-tab-span"> </span>--with-make-prog</span></div>
<div class="p4">
<span class="s1"><span class="Apple-tab-span"> </span>--without-make-prog</span></div>
<div class="p4">
<span class="s1"><span class="Apple-tab-span"> </span>--srcdir=.</span></div>
<div class="p4">
<span class="s1"><span class="Apple-tab-span"> </span>--curdir</span></div>
<div class="p4">
<span class="s1"><span class="Apple-tab-span"> </span>--ruby=/Users/.rbenv/versions/2.1.2/bin/ruby</span></div>
<div class="p4">
<span class="s1">/Users/.rbenv/versions/2.1.2/lib/ruby/2.1.0/fileutils.rb:1573:in `stat': No such file or directory @ rb_file_s_stat - ./212/ruby_debug.h (Errno::ENOENT)</span></div>
<div class="p4">
<span class="s1"><span class="Apple-tab-span"> </span>from /Users/osx/.rbenv/versions/2.1.2/lib/ruby/2.1.0/fileutils.rb:1573:in `block in fu_each_src_dest'</span></div>
<div class="p4">
<span class="s1"><span class="Apple-tab-span"> </span>from /Users/osx/.rbenv/versions/2.1.2/lib/ruby/2.1.0/fileutils.rb:1587:in `fu_each_src_dest0'</span></div>
<div class="p4">
<span class="s1"><span class="Apple-tab-span"> </span>from /Users/mac/.rbenv/versions/2.1.2/lib/ruby/2.1.0/fileutils.rb:1571:in `fu_each_src_dest'</span></div>
<div class="p4">
<span class="s1"><span class="Apple-tab-span"> </span>from /Users/mac/.rbenv/versions/2.1.2/lib/ruby/2.1.0/fileutils.rb:399:in `cp'</span></div>
<div class="p4">
<span class="s1"><span class="Apple-tab-span"> </span>from extconf.rb:83:in `block in <main>'</span></div>
<div class="p4">
<span class="s1"><span class="Apple-tab-span"> </span>from extconf.rb:82:in `each'</span></div>
<div class="p4">
<span class="s1"><span class="Apple-tab-span"> </span>from extconf.rb:82:in `<main>'</span></div>
<div class="p3">
<span class="s1"></span><br /></div>
<div class="p4">
<span class="s1">extconf failed, exit code 1</span></div>
<div class="p3">
<span class="s1"></span><br /></div>
<div class="p4">
<span class="s1">Gem files will remain installed in /Users/work/cucumber-obat24/vendor/ruby/2.1.0/gems/debugger-1.6.8 for inspection.</span></div>
<div class="p4">
<span class="s1">Results logged to /Users/work/cucumber-obat24/vendor/ruby/2.1.0/extensions/x86_64-darwin-13/2.1.0-static/debugger-1.6.8/gem_make.out</span></div>
<div class="p5">
<span class="s1">An error occurred while installing debugger (1.6.8), and Bundler cannot continue.</span></div>
<br />
<div class="p5">
<span class="s1">Make sure that `gem install debugger -v '1.6.8'` succeeds before bundling.</span></div>
<div class="p5">
<span class="s1"><br /></span></div>
<div class="p5">
<span class="s1"><b>After:</b></span></div>
<div class="p5">
<span class="s1"><b><br /></b></span></div>
<div class="p1">
<span class="s1">Using debugger-linecache 1.2.0</span></div>
<div class="p1">
<span class="s1">/Users/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/ext/builder.rb:73: warning: Insecure world writable dir /usr/local in PATH, mode 040777</span></div>
<div class="p2">
<span class="s1">Installing debugger2 1.0.0.beta2</span></div>
<div class="p1">
<span class="s1">Using rubyzip 1.1.0</span></div>
<div class="p1">
<span class="s1">Using ruby-ole 1.2.11.7</span></div>
<div class="p1">
<span class="s1">Using spreadsheet 0.9.6</span></div>
<div class="p1">
<span class="s1">Using roo 1.13.0</span></div>
<div class="p1">
<span class="s1">Using rspec-core 2.14.7</span></div>
<div class="p1">
<span class="s1">Using rspec-expectations 2.14.4</span></div>
<div class="p1">
<span class="s1">Using rspec-mocks 2.14.4</span></div>
<div class="p1">
<span class="s1">Using rspec 2.14.1</span></div>
<div class="p1">
<span class="s1">Using websocket 1.0.7</span></div>
<div class="p1">
<span class="s1">Using selenium-webdriver 2.38.0</span></div>
<div class="p1">
<span class="s1">Using tins 0.13.1</span></div>
<div class="p1">
<span class="s1">Using term-ansicolor 1.2.2</span></div>
<div class="p1">
<span class="s1">Using bundler 1.6.3</span></div>
<div class="p2">
<span class="s1">Your bundle is complete!</span></div>
<div class="p5">
<span class="s1">
</span></div>
<div class="p2">
<span class="s1">It was installed into ./vendor</span></div>
<div class="p5">
<span class="s1"><b><br /></b></span></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6898534150006909939.post-36021658819465939162014-07-10T19:08:00.000+10:002014-07-10T19:09:26.444+10:00(unknown) block sequence entries are not allowed in this context at line 5 column 14 (Psych::Syntax Error)This error come up when I run my cucumber test file.<br />
<br />
Solution: the problem is because in my config.yml file I have an entry with "-".<br />
<br />
So in my config.yml I have the following:<br />
<br />
test_server:<br />
member_no: <b>-</b><br />
member_name: <b>-</b><br />
year: 2014<br />
<br />
To fix the issue, just remove the "-" from config.yml so that ruby can parse the yml file<br />
<br />
test_server:<br />
member_no: 00000010<br />
member_name: cucumber<br />
year: 2014Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-6898534150006909939.post-38241543159747432072014-07-01T11:55:00.000+10:002014-07-01T11:55:16.364+10:00Heroku: Permission denied (publickey)<div class="p1">
<b>Error:</b></div>
<div class="p1">
heroku git:clone -a myapp</div>
<div class="p1">
Cloning from app 'myapp'...</div>
<div class="p1">
</div>
<div class="p1">
Cloning into 'myapp'...</div>
<div class="p1">
The authenticity of host 'heroku.com (50.19.85.154)' can't be established.</div>
<div class="p1">
RSA key fingerprint is 8b:48:5e:67:0e:c9:16:47:32:f2:87:0c:1f:c8:60:ad.</div>
<div class="p1">
Are you sure you want to continue connecting (yes/no)? yes</div>
<div class="p1">
Warning: Permanently added 'heroku.com,50.19.85.154' (RSA) to the list of known hosts.</div>
<div class="p1">
<b>Permission denied (publickey).</b></div>
<div class="p1">
fatal: Could not read from remote repository.</div>
<div class="p2">
<br /></div>
<div class="p1">
Please make sure you have the correct access rights</div>
<br />
<div class="p1">
and the repository exists.</div>
<div class="p1">
<br /></div>
<div class="p1">
<b>Solution:</b></div>
<div class="p1">
<b><br /></b></div>
<div class="p1">
terminal:~ <b>heroku keys:add</b></div>
<div class="p1">
Could not find an existing public key.</div>
<div class="p1">
Would you like to generate one? [Yn] y</div>
<div class="p1">
Generating new SSH public key.</div>
<div class="p1">
</div>
<div class="p1">
Uploading SSH public key /Users/terminal/.ssh/id_rsa.pub... done</div>
<div class="p1">
<br /></div>
<div class="p1">
termina:~ heroku git:clone -a myapp</div>
<div class="p1">
<br /></div>
<div class="p1">
Cloning from app 'myapp'...</div>
<div class="p1">
Cloning into 'myapp'...</div>
<div class="p1">
Fetching repository, done.</div>
<div class="p2">
<br /></div>
<div class="p1">
remote: Counting objects: 2405, done.</div>
<div class="p1">
remote: Compressing objects: 100% (1323/1323), done.</div>
<div class="p1">
</div>
<div class="p1">
Receiving objects: 12% (305/2405), 3.27 MiB | 12.00 KiB/s </div>
<div class="p1">
.</div>
<div class="p1">
.</div>
<div class="p1">
.</div>
<div class="p1">
.</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6898534150006909939.post-56875513712890786962013-08-30T18:08:00.000+10:002013-08-30T18:08:03.461+10:00did not find expected key while parsing a block mapping at line 1 column 1I get the following error when running cucumber, ruby, capybara with selenium webdriver<br />
<br />
It turns out that in my config.yml (features/support/config.yml) I have an extra space:<br />
<br />
"<br />
test_server:<br />
base_url: http://192.168.1.10/test/<br />
<br />
test_server2:<br />
base_url: http://192.168.1.4/test/<br />
"<br />
which should be:<br />
"<br />
test_server:<br />
base_url: http://192.168.1.10/test/<br />
<br />
test_server2:<br />
base_url: http://192.168.1.4/test/<br />
" (no space on "test_server2")<br />
<br />
D:\work\cucumber>bundle exec cucumber features\regression\search.feature<br />
(<unknown>): did not find expected key while parsing a block mapping at line 1 column 1 (Psych::SyntaxError)<br />
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/psych.rb:206:in `parse'<br />
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/psych.rb:206:in `parse_stream'<br />
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/psych.rb:289:in `load_stream'<br />
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/psych/deprecated.rb:28:in `load_documents'<br />
D:/work/cucumber/features/support/lib/configuration.rb:11:in `load'<br />
D:/work/cucumber/features/support/lib/configuration.rb:22:in `<top (required)>'<br />
D:/work/cucumber/features/support/env.rb:12:in `require'<br />
D:/work/cucumber/features/support/env.rb:12:in `<top (required)>'<br />
D:/work/cucumber/vendor/ruby/1.9.1/gems/cucumber-1.3.1/lib/cucumber/rb_support/rb_language.rb:122:in `load'<br />
D:/work/cucumber/vendor/ruby/1.9.1/gems/cucumber-1.3.1/lib/cucumber/rb_support/rb_language.rb:122:in `load_code_file'<br />
D:/work/cucumber/vendor/ruby/1.9.1/gems/cucumber-1.3.1/lib/cucumber/runtime/support_code.rb:180:in `load_file'<br />
D:/work/cucumber/vendor/ruby/1.9.1/gems/cucumber-1.3.1/lib/cucumber/runtime/support_code.rb:83:in `block in load_files!'<br />
D:/work/cucumber/vendor/ruby/1.9.1/gems/cucumber-1.3.1/lib/cucumber/runtime/support_code.rb:82:in `each'<br />
D:/work/cucumber/vendor/ruby/1.9.1/gems/cucumber-1.3.1/lib/cucumber/runtime/support_code.rb:82:in `load_files!'<br />
D:/work/cucumber/vendor/ruby/1.9.1/gems/cucumber-1.3.1/lib/cucumber/runtime.rb:183:in `load_step_definitions'<br />
D:/work/cucumber/vendor/ruby/1.9.1/gems/cucumber-1.3.1/lib/cucumber/runtime.rb:42:in `run!'<br />
D:/work/cucumber/vendor/ruby/1.9.1/gems/cucumber-1.3.1/lib/cucumber/cli/main.rb:47:in `execute!'<br />
D:/work/cucumber/vendor/ruby/1.9.1/gems/cucumber-1.3.1/bin/cucumber:13:in `<top (required)>'<br />
D:/work/cucumber/vendor/ruby/1.9.1/bin/cucumber:23:in `load'<br />
D:/work/cucumber/vendor/ruby/1.9.1/bin/cucumber:23:in `<main>'Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6898534150006909939.post-51414685919835342782013-05-07T18:19:00.001+10:002013-05-07T18:19:10.861+10:00Capybara Hover Over ElementTo emulate mouse hover with Capybara use the following method:<br />
<br />
find(:css, "#menu_bar").hover<br />
<br />
I am using capybara (2.1.0) and selenium-webdriver (2.32.1)<br />
<br />Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-6898534150006909939.post-19332027373075821822012-09-05T10:37:00.003+10:002012-09-05T10:37:37.733+10:00Frame in CapybaraTo access the element in a frame or iframe using capybara use the following within method<br />
<br />
within_frame('iframex') do<br />
fill_in "email", :with => random_email<br />
end<br />
<br />Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6898534150006909939.post-30860303287831445142012-08-22T10:48:00.000+10:002012-08-22T10:48:27.774+10:00Ignore browser untrusted security certificateTo ignore the browser untrusted security certificate so that the cucumber test can be run in the test environment you can modify the env.rb to ignore the warning:
<pre>
require 'selenium/webdriver'
Capybara.register_driver :selenium do |app|
profile = Selenium::WebDriver::Firefox::Profile.new
profile.assume_untrusted_certificate_issuer = false
Capybara::Selenium::Driver.new(app, :browser => :firefox, :profile => profile)
end
</pre>Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-6898534150006909939.post-15809351223601356882012-08-14T09:13:00.004+10:002012-08-14T13:33:23.722+10:00file upload using capybaraTo put the file name into the file upload dialog box with Capybara we can use the following Selenium webdriver method. We can use the Ruby code Dir.pwd to get the current working directory path.
<pre>
page.driver.browser.find_element(:id, "fileUploadId").send_keys
(Dir.pwd + "file upload path")
</pre>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6898534150006909939.post-85889468967771718682012-07-02T10:40:00.001+10:002012-07-02T10:42:22.687+10:00Webdriver can't click element in IEThe issue that I have is that the capybara/selenium webdriver method of click element does not seem to work in IE.
<pre>
find(:css, ".submit").click #does not seem to click the element in IE
</pre>
This method works fine in other browsers like FF. When I try to just find the element by using the
<pre>
find(:css, ".submit")
it can return this: #<Capybara::Element tag="input">
</pre>
Apparently this is because I accidentally change the zoom level in Internet Explorer. To fix this issue simply set the zoom level to be 100%.Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-6898534150006909939.post-80951134962195972502012-06-20T15:56:00.000+10:002012-08-18T15:56:41.954+10:00IE webdriver maximize windowRunning cucumber test with webdriver in Internet Explorer browser has alot of issues. One issue that I encounter is that the IE browser window is not opening in a maximized state. Apparently, webdriver needs to have IE browser fully maximize in order for webdriver to be able to locate elements.
A workaround that I use is to maximize the IE browser on my first cucumber steps.
To change/resize the browser window:
<pre>
#need to check the browser version is IE via webdriver as other browsers like ff and chrome do not to be maximised
if(page.driver.browser.browser.to_s == "internet_explorer")
page.driver.browser.manage.window.maximize
end
</pre>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6898534150006909939.post-27509961475724932672012-06-20T13:45:00.002+10:002012-06-20T13:47:07.256+10:00IE undefined method map for nil classI get the following error when running webdriver in IE 7 and 8. I am using ruby, Capybara with selenium webdriver version 2.2.24
<pre>
Undefined method `map` for nil:NilClass (NoMethodError)
or
NoMethodError Exception: undefined method `map` for nil:NilClass
</pre>
It seems that IE stand alone webdriver could not switch between http to https then to http again correctly and therefore it could not find any of the DOM element.
This also cause the error of unable to delete cookie in IE
<pre>Selenium::WebDriver::Error:JavascriptError Exception: Unable to delete cookie with name 'cookiename'
</pre>
The workaround that I have for this Internet explorer webdriver issue is to start the session with https instead of http. This seem to have solve the issue. Alternatively, during the session you can make the test to visit a https page and then visit the current page again.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6898534150006909939.post-35387425738020909692012-06-20T11:25:00.003+10:002012-06-20T11:29:23.161+10:00Capybara refresh back forward a pageTo refresh a page in Capybara using selenium webdriver simply call the webdriver method directly
<pre>
page.driver.browser.navigate.refresh (to, back, forward)
or
you can use the visit 'url' method
</pre>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6898534150006909939.post-89972318906424670582012-06-20T09:55:00.001+10:002012-06-20T09:55:34.169+10:00Capybara save page methodThis is a pretty useful method to save the current active page for debugging.
This method can be triggered when the scenario fail.
<pre>
After do |scenario|
if scenario.failed?
page.save_page
end
end
</pre>
This will create a file called capybara-timestamp.html in the current directoryUnknownnoreply@blogger.com0tag:blogger.com,1999:blog-6898534150006909939.post-3348288920871978572012-06-19T13:38:00.001+10:002012-06-19T13:55:54.353+10:00Capybara running in IE - Internet ExplorerTo switch capybara to run in IE or different browser:
<pre>
Capybara.register_driver :selenium do |app|
Capybara::Selenium::Driver.new(app, :browser => :internet_explorer)
end
or
Capybara.register_driver :selenium do |app|
Capybara::Selenium::Driver.new(app, :browser => :firefox)
end
or
Capybara.register_driver :selenium do |app|
Capybara::Selenium::Driver.new(app, :browser => :chrome)
end
</pre>
For IE, you just need to download the standalone ie driver from selenium webdriver page <a href=http://code.google.com/p/selenium/downloads/list target=_blank>InternetExplorerDriver</a> otherwise you will get the webdriver warning "the IE driver is moving to a standalone executable... Falling back to bundled DLLs for now.."
You can put the IE standalone driver in your rubyxxx/bin folder.Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-6898534150006909939.post-61909726944572354992012-06-18T13:22:00.000+10:002012-06-20T15:31:31.614+10:00Modal dialog present webdriver ErrorTo surpress the IE security warning modal dialog present (Selenium::WebDriver::Error::UnhandledAlertError) use the following code
</br></br>
Internet Explorer security warning modal dialog box:
</br></br>
"Do you want to view only the webpage content that was delivered securely?
This webpage contains content that will not be delivered using a secure HTTPS connection, which could compromise the security of the entire webpage
"</br></br>
"Internet explorer - This page is accessing information that is not under its control. This poses a security risk. Do you want to continue?" This warning is probably because we are using the IE Standalone selenium webdriver.
The workaround for the issue:
<pre>
begin
click_link "test"
rescue Selenium::WebDriver::Error:UnhandledAlertError => e
# may need to use the page.driver.wait_until method to wait until the alert present other wise you may get the
# No alert is active (Selenium::WebDriver::Error::NoAlertPresentError)
#page.driver.browser.switch_to.alert.accept
#page.driver.browser.switch_to.alert.dismiss
click_link "test"
end
</pre>Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-6898534150006909939.post-72895351228826901952012-06-18T13:03:00.003+10:002012-06-18T13:04:53.344+10:00cucumber undefined method 'step' for errorThis error undefined method `step` for "#<object:0x1a4f9f0>" (NoMethodError) occurs because you are using an older version of cucumber and therefore and older version of the Gherkin gem.<br />
<br />
I was using cucumber 1.0.2 and I got the undefined method 'step' error. I upgraded to cucumber 1.2.1 and it has the method defined.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6898534150006909939.post-41014476784690615142012-06-13T08:24:00.000+10:002012-06-13T08:24:02.592+10:00Installing and managing Ruby version using RVMTo install ruby using RVM please go to this article which also explain on how to switch back and forth between different version of ruby:
<a href=http://pragmaticstudio.com/blog/2010/9/23/install-rails-ruby-mac>Install Ruby Mac</a>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6898534150006909939.post-50528289202162864412012-06-12T11:29:00.000+10:002012-06-12T11:29:24.333+10:00Using 'Given/When/Then' in step definitions is deprecated, use 'step' to call other stepsIf you are getting this warning
"Using 'Given/When/Then' in step definitions is deprecated, use 'step' to call other steps" then just change this line in your steps definitions:
<pre>
Given /^the user logs in$/ do
And 'the user visits the main page'
And 'the user clicks on the login button'
.
.
end
</pre>
To:
<pre>
Given /^the user logs in$/ do
step('the user visits the main page')
step('the user clicks on the login button')
.
.
end
</pre>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6898534150006909939.post-55236060597902594842012-06-12T11:08:00.002+10:002012-06-12T11:08:26.103+10:00term/ansicolor LoadError - cannot load such fileWhen you are using Using cucumber (1.2.1), you may get the cannot load such file -- term/ansicolor (LoadError).
To fix it simply install 'gem install term-ansicolor'Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6898534150006909939.post-81358319284695312302012-05-24T13:29:00.000+10:002012-05-24T13:29:20.933+10:00Capybara using contains to select an elementSuppose you have a select element that has a random number as the id like the one below:
<pre>
< select class="select_xpath_class" name="myMethods[select_method_id_23749837]" id="select_method_id_23749837">
Please select... Select1 Select2 Select3
</select>
</pre>
<br>
Capybara method of select won't work:
<pre>
page.select("Select1", :from => "select_method_id")
</pre>
This is because it will only find the exact match of the id.
<br><br>
To solve this we can use the find method directly with xpath:
<br>
<pre>
find(:xpath, "//*[contains(@id, 'select_method_id')]").select("Select1")
</pre>Unknownnoreply@blogger.com1