【问题标题】:unable to click on ribbon button in Dynamics CRM selenium java无法单击 Dynamics CRM selenium java 中的功能区按钮
【发布时间】:2018-10-15 09:04:13
【问题描述】:

我正在尝试单击 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

【问题讨论】:

  • 嗨!如果您打开 Chrome 控制台 (F12) 并在控制台中输入 "$$("#jwl_bi_newcustomer|NoRelationship|Form|jwl.jwl_bi_newcustomer.Button1.Button")" 会发生什么?它是否返回元素?另外,请查看控制台中的下拉菜单。有 top 和 iframe 之类的值。如果控制台碰巧在控制台中找到该元素,它会自动将视图更改为所需的iframe
  • 语法错误,无法识别的表达式
  • 试试这个:$$("*[id='jwl_bi_newcustomer|NoRelationship|Form|jwl.jwl_bi_newcustomer.Button1.Button']");
  • 我找不到 top 和 iframe 的值。不确定它是否是我上一页中的框架问题我可以单击相同类型的按钮(功能区按钮),但是当我单击下一页旁边时,我的提交按钮出现在表单上方的这些按钮旁边(功能区按钮)一旦将其添加到其中,我就无法单击其中的任何一个。
  • 在顶部,我在框架之前有两件事,它不关注任何东西,对于框架它不会超过我的按钮。它位于我的按钮下方的表单上方。

标签: java eclipse selenium dynamics-crm


【解决方案1】:

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

你也可以使用 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();

【讨论】:

  • 这似乎不是框架问题,我尝试了你所有的建议,但没有一个奏效。没有这样的元素:无法找到元素:{"method":"xpath","selector":"*//li[contains(@id,'jwl_bi_newcustomer.Button1.Button')]"}
  • 我认为它是动态组件,所以每次都会生成新的 id
  • 你建议做什么?
  • 我的意思是刷新页面后 id 保持不变,即“jwl_bi_newcustomer.Button1.Button”或检查
  • 标签是否可点击。通常我们主要点击
  • 它保持不变。 eclipse 无法读取按钮的 id,因为它无法找到它,所以我无法点击它。我尝试使用标题来获取它,但它也没有工作。
  • 猜你喜欢
    相关资源
    最近更新 更多
    热门标签