[Git][noosfero/noosfero][master] 2 commits: Fix selenium onClick link web step

Antonio Terceiro gitlab at mg.gitlab.com
Fri Feb 5 09:22:38 BRST 2016


Antonio Terceiro pushed to branch master at Noosfero / noosfero


Commits:
7c6af440 by Rafael Reggiani Manzo at 2016-02-05T09:14:20-02:00
Fix selenium onClick link web step

The previous fix at 8064b0da19cedbb3d8089e9fd62e208857aea0ef did not
expect links with onClick actions which was specially breaking
the category_block feature.

- - - - -
67ae703f by Antonio Terceiro at 2016-02-05T11:22:11+00:00
Merge branch 'fix_selenium_click_js' into 'master'

Fix selenium onClick link web step

The previous fix at 8064b0da19cedbb3d8089e9fd62e208857aea0ef did not
expect links with onClick actions which was specially breaking
the category_block feature.

See merge request !785
- - - - -


1 changed file:

- features/step_definitions/web_steps.rb


Changes:

=====================================
features/step_definitions/web_steps.rb
=====================================
--- a/features/step_definitions/web_steps.rb
+++ b/features/step_definitions/web_steps.rb
@@ -43,14 +43,29 @@ When /^(?:|I )follow "([^"]*)"(?: within "([^"]*)")?$/ do |link, selector|
       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]
+        link = find_link(link)
+        href = link[:href]
+        onclick = link[:onClick]
 
         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"
+             "Trying to overcome this by:\n"
 
-        visit href
+        onclick_return = true
+
+        unless onclick.nil?
+          warn "\t* Running onClick JS:\n"\
+               "\t\t'#{onclick}'\n"
+          onclick_return = page.execute_script onclick
+        end
+
+        if onclick_return
+          warn "\t* Redirecting you to the link's href:\n"\
+               "\t\t'#{href}'\n"
+
+          visit href
+        end
+
+        warn "\nGood luck and be careful that this may produce hidden links to work on tests!\n"
       else
         raise selenium_error
       end



View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/946300125782da84533147e0f834adb6eafb0ab5...67ae703fdd8810f3a305c7b4693919a6afe54c03
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20160205/c22b9589/attachment.html>


More information about the Noosfero-dev mailing list