robotframework teste extjs app
-
12-11-2019 - |
Pergunta
Eu estou testando um extjs web app usando robotframework e selenium2library, mas eu não posso localizar alguns elementos do HTML porque eles são atribuídos a uma dinâmica de identificação.
Por exemplo:selenium2library não pôde localizar um botão html código como este:
<button type="button" id="ext-gen56" class=" x-btn-text silk-add">create vm</button>
Eu tentei usar detalhes de XPath e expressão css, mas eles não funcionam.Como lidar com esse problema?Qualquer ajuda seria apreciada.
O que as ferramentas que eu usei são robotframework e selenium2library que são utilizados para automático web app de teste.
Parts of my test script:
// filename is A.txt
//this is a resource file including keywords which are used by testcase file
*** Keywords ***
open vmmanager page
[Timeout]
click element xpath=//table[3]/tbody/tr[2]/td[2]/em/button
create vm
[Arguments] ${vm_name} ${input_description}
click element xpath=//table[3]/tbody/tr[2]/td[2]/em/button
click element xpath=//td[2]/table/tbody/tr[2]/td[2]/em/button
click link xpath=//tbody/tr/td[5]/div/a
click link xpath=//tbody/tr/td[7]/div/a
input text xpath=//div/div/input ${vm_name}
click image xpath=//div/div/img
click element xpath=//div[22]/div/div
click image xpath=//div[3]/div/div/img
click element xpath=//div[19]/div/div
name is null
alert should be present ${expect}
click button xpath=//div[2]/div/div/div/div/table/tbody/tr/td/em/button
click button xpath=//td[5]/table/tbody/tr[2]/td[2]/em/button
contact engineer
alert should be present
click button ext-gen311
//filename is B.txt
//this is testcase file
*** Settings ***
Resource fiel A.txt
*** Test Cases ***
VC_VM_01
open vmmanager page
create vm ${empty} description
name is null
VC_VM_03
open vmmanager page
create vm valentine day
contact engineer
Solução
Gostaria apenas de saber como conjunto estático de ids.Se você não tem acesso ao código do aplicativo, gostaria de pedir que os desenvolvedores seria atribuir estático ids para os componentes.- isso seria IMHO a solução mais simples.
Id gerados apenas significa que ninguém ainda se preocupa com eles.
Outras dicas
Sem Identificações, você pode testar usando _near e _under do Sahi estrutura de automação...eu estou usando-o, o seu código Aberto ... tenha paciência para tentar maneiras diferentes para identificar os elementos...é legal e bom...
A maioria dos elementos vai ter de texto presentes nos mesmos.
xpath=//button[contains(text(), 'create vm')]
Uma abordagem genérica será
xpath=//*[contains(text(), 'create vm')]