使用robotframework在登录脚本中添加电子邮件和密码

问题描述 投票:0回答:1

我在RobotFram中创建了这个脚本

*** Settings ***
Documentation               This is a basic test for Linkedin Login
Library                     Selenium2Library

*** Variables ***
${Browser}          chrome
${SiteUrl}          https://www.linkedin.com/
${username}         xpath=//*[@id="login-email"]
${psw}              xpath=//*[@id="login-password"]
${sigin}            xpath=//*[@id="login-submit"]


*** Test Cases ***
Login Page

    open browser    ${SiteUrl}    ${Browser}

    Input Text      ${username} [email protected]
    sleep           30 sec
    Input Text      ${psw} nopsw

    click button    ${sigin}

    close browser

我在“电子邮件”和“密码”字段中插入邮件和密码时遇到问题。

该报告给出了这个错误:

KEYWORD Selenium2Library . Input Text ${username} [email protected]

文档: 将给定的text键入由locator标识的文本字段。

开始/结束/经过时间:20190311 21:59:48.408 / 20190311 21:59:48.408 / 00:00:00.000 21:59:48.408 FAIL关键字'Selenium2Library.Input Text'需要2个参数,得1。

error-handling robotframework login-script
1个回答
4
投票

错误解释了自己:

FAIL关键字'Selenium2Library.Input Text'预计2个参数,得1。

该命令期待两个参数,但它只有一个,原因是你只在args之间使用一个空格,它们之间至少需要两个或更多的空格。所以这:

Input Text      ${username} [email protected]

应该是这样的:

Input Text      ${username}     [email protected]

就像:open browser ${SiteUrl} ${Browser}

© www.soinside.com 2019 - 2024. All rights reserved.