ho avuto un caso strano in cui alcuni test di fumo hanno marciato attraverso le varie pagine di login customer-centric che hanno avuto lievi variazioni sul fare il login pulsante di invio ... Guidato da una tabella di cetriolo di utente, org , eccetera.
# 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
fonte
2013-08-04 15:08:15
Stavo per farlo a causa dei collegamenti Javascript, ma poi ho deciso di non: in questo caso almeno, * è * possibile distinguere. Ad esempio, al centro clic si apre una nuova scheda e, al passaggio del mouse, la destinazione del collegamento viene visualizzata solo per il collegamento. La migliore pratica è: non usare i collegamenti in quel caso e non permetterli nei test. –
C'è comunque un caso in cui ne vale la pena: la negazione. Altrimenti, se si cambiano i collegamenti in pulsanti, i test diventano automaticamente silenziosi. –