Commit 10207b39465fa383e81b245b0ca5e8161e5b0fba

Authored by Daniel Cunha
Committed by Daniela Feitosa
1 parent 26e34d90

removing selenium steps

Showing 1 changed file with 0 additions and 133 deletions   Show diff stats
features/step_definitions/selenium_steps.rb
@@ -1,133 +0,0 @@ @@ -1,133 +0,0 @@
1 -require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))  
2 -  
3 -def string_to_element_locator(selector)  
4 - if selector.gsub!(/^\./, '')  
5 - "css=[class='#{selector}']"  
6 - elsif selector.gsub!(/^value[.=]/, '')  
7 - "xpath=//input[@value='#{selector}']"  
8 - elsif selector.gsub!(/^option=/, '')  
9 - "xpath=//option[@value='#{selector}']"  
10 - elsif selector.gsub!(/^#/, '')  
11 - "css=[id='#{selector}']"  
12 - elsif selector.gsub!(/^content=/, '')  
13 - "xpath=//*[.='#{selector}']"  
14 - elsif selector.gsub!(/^li=/, '')  
15 - "xpath=//li[contains(.,'#{selector}')]"  
16 - else  
17 - selector  
18 - end  
19 -end  
20 -  
21 -Then /^the "([^\"]*)" should be visible$/ do |selector|  
22 - (selenium.is_element_present(string_to_element_locator(selector)) && selenium.is_visible(string_to_element_locator(selector))).should be_true  
23 -end  
24 -Then /^the content "([^\"]*)" should be visible$/ do |selector|  
25 - selenium.is_visible(string_to_element_locator("content=#{selector}")).should be_true  
26 -end  
27 -  
28 -Then /^the "([^\"]*)" should not be visible$/ do |selector|  
29 - (selenium.is_element_present(string_to_element_locator(selector)) && selenium.is_visible(string_to_element_locator(selector))).should be_false  
30 -end  
31 -Then /^the content "([^\"]*)" should not be visible$/ do |selector|  
32 - selenium.is_visible(string_to_element_locator("content=#{selector}")).should be_false  
33 -end  
34 -  
35 -When /^I click "([^\"]*)"$/ do |selector|  
36 - selenium.click(string_to_element_locator(selector))  
37 -end  
38 -  
39 -Then /^the "([^\"]*)" button should not be enabled$/ do |text|  
40 - selenium.is_editable(string_to_element_locator(text)).should be_false  
41 -end  
42 -  
43 -Then /^the "([^\"]*)" button should be enabled$/ do |text|  
44 - selenium.is_editable(string_to_element_locator("value.#{text}")).should be_true  
45 -end  
46 -  
47 -Then /^I should see "([^\"]*)" above of "([^\"]*)"$/ do |above, below|  
48 - above_position = selenium.get_element_position_top(string_to_element_locator("li=#{above}"))  
49 - below_position = selenium.get_element_position_top(string_to_element_locator("li=#{below}"))  
50 - above_position.to_i.should < below_position.to_i  
51 -end  
52 -  
53 -When /^I drag "([^\"]*)" to "([^\"]*)"$/ do |from, to|  
54 - selenium.drag_and_drop_to_object(string_to_element_locator("li=#{from}"), string_to_element_locator("li=#{to}"))  
55 - selenium.wait_for_ajax  
56 -end  
57 -  
58 -When /^I select "([^\"]*)" and wait for (jquery)$/ do |value, framework|  
59 - select(value)  
60 - # FIXME ugly hack to make selenium tests waiting to render page  
61 - # "select(value, :wait_for => :ajax)" did not effect  
62 - selenium.wait_for(:wait_for => :ajax, :javascript_framework => framework)  
63 -end  
64 -  
65 -When /^I select window "([^\"]*)"$/ do |selector|  
66 - selenium.select_window(selector)  
67 -end  
68 -  
69 -When /^I fill in "([^\"]*)" within "([^\"]*)" with "([^\"]*)"$/ do |field_label, parent_class, value|  
70 - selenium.type("xpath=//*[contains(@class, '#{parent_class}')]//*[@id=//label[contains(., '#{field_label}')]/@for]", value)  
71 -end  
72 -  
73 -When /^I press "([^\"]*)" within "([^\"]*)"$/ do |button_value, selector|  
74 - selenium.click("css=#{selector} input[value=#{button_value}]")  
75 - selenium.wait_for_page_to_load(10000)  
76 -end  
77 -  
78 -Then /^there should be ([1-9][0-9]*) "([^\"]*)" within "([^\"]*)"$/ do |number, child_class, parent_class|  
79 - # Using xpath is the only way to count  
80 - response.selenium.get_xpath_count("//*[contains(@class,'#{parent_class}')]//*[contains(@class,'#{child_class}')]").to_i.should be(number.to_i)  
81 -end  
82 -  
83 -Then /^"([^\"]*)" should be (left|right) aligned$/ do |element_class, align|  
84 - # Using xpath is the only way to count  
85 - response.selenium.get_xpath_count("//*[contains(@class,'#{element_class}') and contains(@style,'float: #{align}')]").to_i.should be(1)  
86 -end  
87 -  
88 -When /^I confirm$/ do  
89 - selenium.get_confirmation  
90 -end  
91 -  
92 -When /^I type "([^\"]*)" in TinyMCE field "([^\"]*)"$/ do |value, field_id|  
93 - response.selenium.type("dom=document.getElementById('#{field_id}_ifr').contentDocument.body", value)  
94 -end  
95 -  
96 -When /^I refresh the page$/ do  
97 - response.selenium.refresh  
98 -end  
99 -  
100 -When /^I click on the logo$/ do  
101 - selenium.click("css=h1#site-title a")  
102 - selenium.wait_for_page_to_load(10000)  
103 -end  
104 -  
105 -When /^I open (.*)$/ do |url|  
106 - selenium.open(URI.join(response.selenium.get_location, url))  
107 -end  
108 -  
109 -Then /^the page title should be "([^"]+)"$/ do |text|  
110 - selenium.get_text("//title").should == text  
111 -end  
112 -  
113 -#### Noosfero specific steps ####  
114 -  
115 -Then /^the select for category "([^\"]*)" should be visible$/ do |name|  
116 - sleep 2 # FIXME horrible hack to wait categories selection scolling to right  
117 - category = Category.find_by_name(name)  
118 - selenium.is_visible(string_to_element_locator("option=#{category.id}")).should be_true  
119 -end  
120 -  
121 -When /^I follow "([^\"]*)" and sleep ([^\"]*) seconds?$/ do |link, time|  
122 - click_link(link)  
123 - sleep time.to_i  
124 -end  
125 -  
126 -When /^I follow "([^\"]*)" and wait for jquery$/ do |link|  
127 - click_link(link)  
128 - selenium.wait_for(:wait_for => :ajax, :javascript_framework => framework)  
129 -end  
130 -  
131 -When /^I leave the "([^\"]+)" field$/ do |field|  
132 - selenium.fire_event("css=#{field}", "blur")  
133 -end