[Git][noosfero/noosfero][master] 3 commits: Fix selenium click link web step

Antonio Terceiro gitlab at mg.gitlab.com
Mon Feb 1 10:14:12 BRST 2016


Antonio Terceiro pushed to branch master at Noosfero / noosfero


Commits:
8064b0da by Rafael Reggiani Manzo at 2016-01-30T14:23:03-02:00
Fix selenium click link web step

Selenium tests were broken in clicking inside the content selection box.

Some HTML structures, such as `<li>` tags nested to `<a>` tags, may not
get along with Selenium and the browser interaction. But are perfectly
fine for the final user.

As we do not want to modify the current behaviour in order to pass
tests, here we handle Selenium's error properly so tests can still pass
without modifying current code.

NOTICE: This only works with selenium-webdriver 2.50.0 and up.

- - - - -
fdc3d92a by Antonio Terceiro at 2016-02-01T10:07:39-02:00
Require selenium-webdriver >= 2.50

- - - - -
56979079 by Antonio Terceiro at 2016-02-01T10:11:37-02:00
Merge branch 'fix_selenium_click_link' of https://gitlab.com/rafamanzo/noosfero

- - - - -


2 changed files:

- Gemfile
- features/step_definitions/web_steps.rb


Changes:

=====================================
Gemfile
=====================================
--- a/Gemfile
+++ b/Gemfile
@@ -75,7 +75,7 @@ group :cucumber do
   gem 'cucumber'
   gem 'cucumber-rails',         '~> 1.4.2', :require => false
   gem 'database_cleaner',       '~> 1.3'
-  gem 'selenium-webdriver'
+  gem 'selenium-webdriver',     '>= 2.50'
 end
 
 # Requires custom dependencies


=====================================
features/step_definitions/web_steps.rb
=====================================
--- a/features/step_definitions/web_steps.rb
+++ b/features/step_definitions/web_steps.rb
@@ -39,7 +39,22 @@ end
 
 When /^(?:|I )follow "([^"]*)"(?: within "([^"]*)")?$/ do |link, selector|
   with_scope(selector) do
-    click_link(link, :match => :prefer_exact)
+    begin
+      click_link(link, :match => :prefer_exact)
+    rescue Selenium::WebDriver::Error::UnknownError => selenium_error
+      if selenium_error.message.start_with? 'Element is not clickable at point'
+        href = find_link(link)[:href]
+
+        warn "#{selenium_error.message}\n\n"\
+             "Trying to overcome this by redirecting you to the link's href:\n"\
+             "\t'#{href}'\n\n"\
+             "Good luck and be careful that this may produce hidden links to work on tests!\n"
+
+        visit href
+      else
+        raise selenium_error
+      end
+    end
   end
 end
 



View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/a3cf9ea480e01c964680a22d4491a7801e68e8eb...5697907969f48ef731a511049cc8898381f3df44
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20160201/a16d8aff/attachment.html>


More information about the Noosfero-dev mailing list