gpt4 book ai didi

java - 撰写邮件点击在 Selenium 中不起作用

转载 作者:行者123 更新时间:2023-12-02 01:58:30 25 4
gpt4 key购买 nike

在 Gmail 中成功登录后,我无法点击撰写邮件按钮。它给出了 NoSuchElementException 错误。

执行邮件.java

public void clickin(String objectname) throws Exception{    
WebDriverWait wait=new WebDriverWait(driver,20);
WebElement element=wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(prop.getProperty(objectname))));
element.click();
}

关键字.java

if(a.get(i).equals("clickin")) {
String Keyword = (String)a.get(i);
String data = (String)a.get(i+1);
String objectname = (String)a.get(i+2);
String runmode = (String)a.get(i+3);
System.out.println(Keyword);
System.out.println(data);
System.out.println(objectname);
System.out.println(runmode);
if(runmode.equals("Yes")) {
key.clickin(objectname);
}
}

enter image description here

最佳答案

仔细检查您的定位器,对我来说是以下XPath expression工作正常:

//div[@role='button' and normalize-space()='Compose']

它过滤 div角色划分的元素 attribute并使用normalize-space() function忽略空格和换行符

enter image description here

关于java - 撰写邮件点击在 Selenium 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57386515/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com