selenium workshop
TRANSCRIPT
Selenium workshop
by Ronald Kaiser
Overview (ou uma tentativa)
MotivaoCaractersticasComponentesO SelensSintaxeLocalizando elementosCommand setSelenium IDEFerramentas auxiliaresGotcha's e dicasStop! - Selenium IDE hands onSelenium RCStop! - Selenium RC hands onSelenium na intelie....
Motivao
(aviso)
Motivao
Dedo do estagirio que realizava testes 'na mo'
Motivao
Automatizar testes !
Caractersticas
Caractersticas
Open source (Apache 2.0 license)
Suporte a maioria dos browsers: (Firefox 2/3, Safari 1/2/3, Opera 8/9, Google Chrome, um tal de IE 7/8, outro (RC))
Muito simples: curva de aprendizado suave
API (Selenium RC) para diversas linguagens: HTML, Java, C#, Perl, PHP, Python and Ruby
Componentes
Componentes
IDERCGrid
O Selens
Conjunto de comandos que o Selenium entende.
Sintaxe
Very simple!Command Target Value
Localizando elementos
Localizando elementos
Command Target ValuelocatorType=location
Localizando elementos
Locator types:
IdentifierDOMXPATH
Localizando elementos - Identifier
Retorna o primeiro elemento com o dado id/name
HTML:
Selenium target:identifier=loginForm
Localizando elementos - DOM
Javascript document way
HTML:
Selenium target:dom=document.getElementById('loginForm')
Localizando elementos - XPath
XPath foi criado especificamente para navegar entre os elementos e atributos de um documento XML.
HTML:
Selenium target:xpath=//form[@id='loginForm']
Command set
Command set
Actions
Accessors
Assertions
Command set - Actions
Alteram o estado da aplicao
opencheckclickAndWaitfocuskeyPresstypeclose
....
Command set - Accessors
Examinam o estado da aplicao e armazenam seus resultados em variveis
storeElementHeightstoreElementPositionLeftstoreEvalstoreValue....
Command set - Assertions
Verificam se o estado da aplicao est de acordo com o esperado
assertAllLinksassertConfirmationassertTextPresentassertTitle....
Selenium IDE
Ferramentas Auxiliares
Plugins p/ firefox:FirebugXPath Checker
Stop! Selenium IDE hands on
Gotcha's e dicas
Gotcha's e dicas
No dependa da estrutura
No defina locators como esse:
xpath=//body/div/div/a[contains(text(), 'bug tracker')]
Dependente da estrutura do DOM
Difcil manuteno!
Gotcha's e dicas
Tempo de carregamento: aplicaes AJAX
Actions do tipo /(.*)andWait/ no funcionam com AJAXUse /waitFor(.*)/
Ex.:
waitForElementPresentwaitForVisible
Selenium RC
Stop! Selenium RC hands on
Selenium na
Quem usa Ext?
AdobeAetnaAIGAlcatel-LucentAmazon.comBest BuyBoeingBorlandCACanonCapgeminiCiscoCNNDow Jones & Co.EMCFidelityGeneral ElectricHallmarkHPHSBCIBMMott MacDonaldNATONetAppNortelNorthrop GrummanPanasonicPixar Animation StudiosQualcomm, Inc.S&PSAPSiemensSonySymantecVisa Internationalmore
Problema
And /^I have added a "([^\"]*)" property with a "([^\"]*)" type$/ do |name, type| @browser.wait_for_element_present "//div[contains(@class, 'stream-form')]//div[contains(@class, 'x-grid3-row-first')]//tr//*[contains(text(), 'Nome')]" @browser.click_at "//div[contains(@class, 'stream-form')]//div[contains(@class, 'x-grid3-row-first')]//tr//*[contains(text(), 'Nome')]", "0,0" @browser.wait_for_element_present "//div[contains(@class, 'stream-form')]//div[contains(@class, 'x-small-editor')]//input" @browser.wait_for_editable "//div[contains(@class, 'stream-form')]//div[contains(@class, 'x-small-editor')]//input"@browser.type "//div[contains(@class, 'stream-form')]//div[contains(@class, 'x-small-editor')]//input[parent::div[not(contains(@style, 'hidden'))]]", "#{name}" @browser.wait_for_element_present "//div[contains(@class, 'stream-form')]//div[contains(@class, 'x-small-editor')]//input[parent::div[not(contains(@style, 'hidden'))]]" @browser.click_at "//div[contains(@class, 'stream-form')]//div[contains(@class, 'x-grid3-row-first')]//tr//td[4]", "0,0" @browser.wait_for_element_present "//div[contains(@class, 'stream-form')]//div[contains(@class, 'x-small-editor')]//input[contains(@class, 'x-form-focus')]" @browser.click_at "//div[contains(@class, 'stream-form')]//div[contains(@class, 'x-small-editor')]//input[contains(@class, 'x-form-focus')]", "0,0" @browser.wait_for_element_present "//div[contains(@class, 'x-combo-list-item') and contains(text(),'#{type}')]" @browser.click_at "//div[contains(@class, 'x-combo-list-item') and contains(text(),'#{type}')]", "0,0"
nosso problema + popularidade do Ext
=
selenium-extjs
selenium-extjs
Framework para testar aplicaes Ext com Selenium
selenium-extjs
gem install selenium-extjs
git://github.com/cathoderay/selenium-extjs.git
Obrigado!
Muokkaa otsikon tekstimuotoa napsauttamalla
Muokkaa jsennyksen tekstimuotoa napsauttamallaToinen jsennystasoKolmas jsennystasoNeljs jsennystasoViides jsennystasoKuudes jsennystasoSeitsems jsennystasoKahdeksas jsennystasoYhdekss jsennystaso