首页 > 解决方案 > 无法单击 Dynamics CRM selenium java 中的功能区按钮

问题描述

我正在尝试单击 Dynamics crm 上的功能区按钮,但它无法以任何方式看到它

结果:没有这样的元素

这是我的代码(java-selenium)这个元素:

Actions act=new Actions(driver);
act.moveToElement(driver.findElement(By.id("jwl_bi_newcustomer|NoRelationship|Form|jwl.jwl_bi_newcustomer.Button1.Button")));
act.click();
act.build().perform();  

这是我的html

从图像查看代码

标签: javaeclipseseleniumdynamics-crm

解决方案


当您处理时,您首先需要在实际找出元素之前切换到它们。

您也可以使用 xpath 找到元素,

driver.findElement(By.XPath("*//li[contains(@id,'jwl_bi_newcustomer.Button1.Button')]"))

所以,尝试使用切换您所需的 iframe,

driver.switchTo().frame(driver.findElement(By.id("jwl_bi_newcustomer|NoRelationship|Form|jwl.jwl_bi_newcustomer.Button1.Button")));

然后尝试找到那个元素

Actions act=new Actions(driver);
act.moveToElement(driver.findElement(By.id("jwl_bi_newcustomer|NoRelationship|Form|jwl.jwl_bi_newcustomer.Button1.Button")));
act.click();
act.build().perform();

再来早点使用框架,

 driver.switchTo().parentFrame();
 driver.switchTo().defaultContent();

推荐阅读