मैं एक अजीब मामले में जहां कुछ धुआं परीक्षण विभिन्न ग्राहक केंद्रित प्रवेश पृष्ठों जिसे प्रवेश कर रही पर मामूली बदलाव किया था सबमिट बटन ... उपयोगकर्ता की एक ककड़ी मेज से प्रेरित भर में मार्च किया था करते हैं, ऑर्ग , आदि।
# A bit of a hack, org_name is normally a subdomain, but sometimes it is the complete domain
def login(user, org_name)
# Use the below to automatically hit each user's org's server
if org_name.include? '.com'
Capybara.app_host = "http://#{org_name}"
else
Capybara.app_host = "http://#{org_name}.mydomain.com"
end
visit '/'
fill_in 'username', :with => user
fill_in 'userpwd', :with => '***'
begin
page.find(:link_or_button, 'submit')
click_on 'submit'
rescue Capybara::ElementNotFound
page.find(:link_or_button, 'Log In')
click_on 'Log In'
rescue Capybara::ElementNotFound
pending "Need to determine how to invoke the Login button for #{org_name} near Line ##{__LINE__} of #{__method__} in #{__FILE__} "
end
# -----------------------
# Work-around for modal popup saying SSL is mismatched if you are using actual production URLs
# The rescue is for cases that do not exhibit the modal pop-up
page.driver.browser.switch_to.alert.accept rescue Selenium::WebDriver::Error::NoAlertPresentError
# Ensure that login was successful
page.should_not have_content 'Login failed'
end
स्रोत
2013-08-04 15:08:15
मैं जावास्क्रिप्ट लिंक के कारण ऐसा करने जा रहा था, लेकिन फिर मैंने यह नहीं करने का फैसला किया: इस मामले में कम से कम, यह * अंतर करना संभव है। उदाहरण के लिए, मध्य पर एक नया टैब खुलता है, और होवर पर लिंक गंतव्य केवल लिंक के लिए दिखाया जाता है। सबसे अच्छा अभ्यास है: उस मामले में लिंक का उपयोग न करें, और परीक्षणों में उन्हें अनुमति न दें। –
एक मामला है हालांकि यह इसके लायक है: अस्वीकृति। अन्यथा, यदि आप बटनों में लिंक बदलते हैं तो परीक्षण चुपचाप हमेशा गुजरते हैं। –