【问题标题】:Testing Phone Number using Selenium使用 Selenium 测试电话号码
【发布时间】:2017-03-02 14:38:31
【问题描述】:

我的项目经理给了我一个任务,他让我“使用 selenium 测试电话号码”。他要求我涵盖所有可能的测试用例来测试电话号码

测试用例如下: 1. 电话号码只能包含数字。 2.电话号码长度应为10。 3. 它不应包含字母。 4. 不应包含符号。 5. 不得包含字母数字组合。 6.电话号码不能以0开头。

请帮助我在自动化中测试所有这些测试用例。

【问题讨论】:

  • 您的个人资料显示您是高级测试工程师。
  • 你谷歌“selenium”并写下代码怎么样...如果你遇到困难,请在此处添加相关代码以供他人查看。

标签: selenium testing automation


【解决方案1】:

我符合上述 cmets,同意;我也不容忍回答这样的问题,但是这样的事情在 selenium 中非常容易,我不会花很长时间来写。

这都是java中的伪代码。

void testCase1() {
  // digits only
  setPhoneNumber("+12345a5434")
  clickSubmit()
  validateErrorMessage("ERROR: Your phone number contains letters")
}

void testCase2() {
  // length should be ten
  setPhoneNumber("+123456789")
  clickSubmit()
  validateErrorMessage("ERROR: Phone numbers should be ten-digits long")
}

void testCase3() {
  testCase1()  // this test case is the exact same as #1
}

void testCase4() {
  setPhoneNumber("+|123456t890")
  clickSubmit()
  validateErrorMessage("ERROR: Your phone number contains invalid characters")
}

void testCase5() {
  testCase1()
  testCase3()
  testCase4()
  // already covered in both these cases
}

void testCase6() {
  setPhoneNumber("+0123456789")
  clickSubmit()
  validateErrorMessage("ERROR: your phone number starts with 0")
}

void validTestCase() {
  setPhoneNumber("+1234567890")
  clickSubmit()
  validateErrorMessage(null)
  validateElementPresent(".success")
}

请注意,这都是伪代码。您没有指定您使用的是哪种语言,也没有指定任何 html。我不容忍回答这类问题——但你的任务很简单,我想我会用伪代码写出来。

【讨论】:

    猜你喜欢
    • 2018-07-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多