【问题标题】:robot framework element with locator not found找不到带有定位器的机器人框架元素
【发布时间】:2018-12-04 21:56:14
【问题描述】:

我在使用 RIDE 编辑器在机器人框架中测试我的应用程序时遇到以下错误。

找不到带有定位符'xpath: //*[contains(text(), "Applicant")]'的元素。

但我的 HTML 页面包含 Applicant 文本

当我使用“Applicant1”编辑该名称时,错误消失了。但我不能在我的应用程序中将其作为“Applicant1”。我希望 Applicant 在我的 HTML 页面中。

我正在为我的应用程序使用 Angular4。申请人来自侧面菜单,它来自 Cupa 菜单 npm 库 以下是显示我如何使用该申请人在 HTML 页面上显示的代码。

下面是.ts文件

 menuItemsArray: any[] = [

    { 'title': 'Loan Application', 'link': 'loan-creation',
        'subItems': [
        { 'title': 'Create Loan Application', 'link': 'loan-creation' },
        { 'title': 'List Of Loan Applications', 'link': 'list-of-loan-application' },
        { 'title': 'Loan Application Details', 'link': 'get-loan-details-by-id' },
      ]
    },
       {
                    'title': 'Applicant', 'link': 'applicant-creation',
                        'subItems': [
                            { 'title': 'Create New Applicant', 'link': 'applicant-creation' },
                            { 'title': 'List Of Applicants', 'link': 'list-of-consumer' },
                        ]
                }
 ];

下面是.html文件

<nav class="navbar navbar-expand-md top-navbar jh-navbar">
     <cuppa-slidemenu name="cupaBar" [menulist]="menuItemsArray" [config]="menuConfig"  (open)="onMenuOpen()" (close)="onMenuClose()" (onItemSelect)="onItemSelect($event)"></cuppa-slidemenu>

  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault"
  aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
    <span class="fa fa-navicon"></span>
  </button>

请帮帮我

Click CreateApplicant Click Element xpath: //*[contains(text(), "Applicant")]

我使用上面的代码点击“Applicant”文本。但它不起作用。名称为“Applicant” 它仅适用于“Applicant1”。此外,它还可以与贷款申请、创建贷款申请等其他选项一起使用。

【问题讨论】:

  • 如果您为问题提供相关的 HTML 会很好

标签: html selenium robotframework angular4-forms


【解决方案1】:

如果您确定文本不会在其他任何地方重复,那么您可以使用

Click CreateApplicant
    Click Element    xpath: //*[contains(., "Applicant")]

【讨论】:

  • 是的。我确定。我的代码中没有重复此文本
  • WebDriverException:消息:未知错误:无法在“窗口”上执行“getComputedStyle”:参数 1 不是“元素”类型。
  • 我可能无法帮助您解决该错误。您能否使用您尝试过的代码和错误更新您的线程。可能是其他人可以帮助你
【解决方案2】:

试试:

Click CreateApplicant
    Click Element    xpath: //*[contains(text(), "applicant-creation")]

【讨论】:

  • 这时你得到申请者是不行的,只有这样你才能点击“申请者创建”。因为它是申请人的子菜单
  • 你试过了吗?因为这个'title': 'Applicant', 'link': 'applicant-creation'它可以工作
  • 它不能工作,因为点击申请人后它会展开,并且只有在申请人创建可见之后。
【解决方案3】:

试试这个:

点击 CreateApplicant 点击元素 xpath: //"[starts-with(@text,"applicant-creation")]

【讨论】:

    猜你喜欢
    • 2015-11-11
    • 2020-03-19
    • 1970-01-01
    • 2019-11-21
    • 2021-03-16
    • 2023-03-04
    • 2014-09-29
    • 2018-10-20
    • 2018-08-16
    相关资源
    最近更新 更多