Loading repository data…
Loading repository data…
welli7ngton / repository
Um repositório dedicado ao tutorial da ferramenta de RPA robotframework.
Este guia fornece uma estrutura detalhada sobre como escrever expressões XPath eficazes para automação de testes com o Robot Framework. XPath é uma linguagem usada para navegar por elementos e atributos em um documento XML ou HTML, essencial para localizar elementos em páginas web.
XPath permite selecionar elementos em um documento XML ou HTML com base em diversos critérios. Existem dois tipos principais de seletores XPath:
xpath
/html/body/div[1]/div[2]/a
xpath
//div[@class='example']/a
xpath
//tagname
xpath
//button
xpath
//tagname[@attribute='value']
xpath
//input[@id='username']
xpath
//tagname[text()='value']
xpath
//button[text()='Submit']
contains()
xpath
//tagname[contains(@attribute, 'value')]
xpath
//a[contains(@href, 'login')]
starts-with()
xpath
//tagname[starts-with(@attribute, 'value')]
xpath
//div[starts-with(@class, 'header')]
xpath
//tagname[@attribute1='value1' and @attribute2='value2']
xpath
//input[@type='text' and @name='username']
Hierarquia de Elementos
xpath
//parentTag/childTag
xpath
//div/form/input
Configurando o Ambiente No arquivo de teste do Robot Framework (.robot), importe a biblioteca SeleniumLibrary para usar seletores XPath.
*** Settings ***
Library SeleniumLibrary
*** Variables ***
${URL} https://example.com
*** Test Cases ***
Test Example
Open Browser ${URL} Chrome
# Localizar elemento por XPath absoluto
Click Element /html/body/div[1]/div[2]/a
# Localizar elemento por XPath relativo
Input Text //input[@id='username'] myusername
Click Button //button[text()='Submit']
Close Browser