【发布时间】:2021-03-12 20:41:04
【问题描述】:
我正在尝试在使用 VueJs 的单页应用程序中开发自动化测试,当我单击注册按钮时,页面会加载包含元素的表单,但是当元素根据需要加载时,它们不会自动出现在那里我可以解决单击注册按钮后放置 driver.sleep 的问题,但我正在寻找一种解决方法我尝试了 ImplicitWaits 和 elementIsEnabled 但我无法获得结果,请在此处查看我的代码:
const { Builder, By, Key, until } = require('selenium-webdriver')
异步函数 teste() {
const driver = await new Builder().forBrowser('chrome').build()
await driver.get('https://dez.dev.dav.med.br/login')
let element = (By.xpath('//*[contains(text(), "Faça seu cadastro")]'))
let query = await robo(element,driver)
await query.click()
await driver.sleep(2000)
element = (By.xpath('//*[contains(@title, "Nome")]'))
query = await robo(element, driver)
await query.sendKeys("VictorTesteRobo2")
element = (By.xpath('//input[contains(@title, "CPF")]'))
query = await robo(element, driver)
await query.sendKeys("11043017844")
element = (By.xpath('//*[contains(@class,"v-select__selections")]'))
query = await robo(element, driver)
await query.click()
element = (By.xpath('//*[contains(text(),"Masculino")]'))
query = await robo(element, driver)
await query.click()
element = (By.xpath('//*[contains(@title, "Data de Nascimento")]'))
query = await robo(element, driver)
await query.sendKeys("06031997")
element = (By.xpath('//*[contains(@title, "E-mail")]'))
query = await robo(element, driver)
await query.sendKeys("teste@email.com")
element = (By.xpath('//*[contains(@title, "Celular")]'))
query = await robo(element, driver)
await query.sendKeys("11995841105")
element = (By.xpath('//*[contains(text(), "Próximo")]'))
query = await robo(element, driver)
await query.click()
element = (By.xpath('//*[contains(text(), "Aceito e Cadastre-me")]'))
query = await robo(element, driver)
await query.click()
}
teste()
异步函数 robo(element, driver, TIMEOUT=10000){
const locator = await driver.wait(until.elementLocated(element, TIMEOUT))
const query = await driver.wait(until.elementIsVisible(locator, TIMEOUT))
return query
}
【问题讨论】:
-
is clickable.Search this site with clickable and you will find solution
-
Js中的Selenium库好像没有isClickable功能
标签: javascript selenium vue.js