【发布时间】:2021-07-13 15:04:40
【问题描述】:
我的 Xpath 正确且没有 iFrame,我可以在 Chrome 控制台中找到元素,但我的程序仍然失败。我也使用了显式等待。
没有这样的元素:无法定位元素:{"method":"xpath","selector":"//*[contains(@ng-click,'authenticationCtrl.onSubmitMage()')]"}
我用 Try xpath 测试了我的 xpath,它可以工作,但是当我编译我的代码时,我仍然收到错误
页面对象:
package com.orange.pageObject;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.CacheLookup;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
public class MageReferentiel {
WebDriver webdriver;
public MageReferentiel(WebDriver rwebDriver) {
webdriver = rwebDriver;
PageFactory.initElements(webdriver, this);
}
@FindBy(xpath = "//*[contains(@ng-click,'authenticationCtrl.onSubmitMage()')]")
@CacheLookup
WebElement connexion;
public void clickConnexion() {
connexion.click();
}
步骤定义:
@When("l utilisateur choisi le referentiel")
public void l_utilisateur_choisi_le_referentiel() throws Exception {
mr.clickConnexion();
Thread.sleep(3000);
}
我想点击按钮
谢谢
【问题讨论】:
标签: java selenium xpath webdriver