本文详细介绍了Selenium IDE中的assert系列命令,包括assert的各种变体,如assert alert、assert checked等,用于在自动化测试中验证元素状态、提示框文本等。文章还列举了每个命令的参数和使用注意事项,帮助理解它们在测试流程中的作用。 摘要由CSDN通过智能技术生成

使用断言,测试用例将会在断言失败后停止运行
优点:可以直接直接了当的看到检查是否通过
缺点:若检查失败,后续的检查不会被执行,无法收集检查的结果状态

assert
assert alert
assert checked
assert confirmation
assert editable
assert element present
assert element not present
assert not checked
assert not editable
assert not selected value
assert not text
assert prompt
assert selected value
assert selected label
assert text
assert title
assert value

官方API

assert

Check that a variable is an expected value. The variable's value will be converted to a string for comparison. The test will stop if the assert fails.

arguments

  • variable name : The name of a variable without brackets.

  • expected value : The result you expect a variable to contain (e.g., true, false, or some other value).

  • assert alert

    Confirm that an alert has been rendered with the provided text. The test will stop if the assert fails.

    arguments

  • alert text : text to check
  • assert checked

    Confirm that the target element has been checked. The test will stop if the assert fails.

    arguments

  • locator : An element locator.
  • assert confirmation

    Confirm that a confirmation has been rendered. The test will stop if the assert fails.

    arguments

  • text : The text to use.
  • assert editable

    Confirm that the target element is editable. The test will stop if the assert fails.

    arguments

  • locator : An element locator.
  • assert element present

    Confirm that the target element is present somewhere on the page. The test will stop if the assert fails.

    arguments

  • locator : An element locator.
  • assert element not present

    Confirm that the target element is not present anywhere on the page. The test will stop if the assert fails.

    arguments

  • locator : An element locator.
  • assert not checked

    Confirm that the target element has not been checked. The test will stop if the assert fails.

    arguments

  • locator : An element locator.
  • assert not editable

    Confirm that the target element is not editable. The test will stop if the assert fails.

    arguments

  • locator : An element locator.
  • assert not selected value

    Confirm that the value attribute of the selected option in a dropdown element does not contain the provided value. The test will stop if the assert fails.

    arguments

  • select locator : An element locator identifying a drop-down menu.

  • text : An exact string match. Support for pattern matching is in the works. See https://github.com/SeleniumHQ/selenium-ide/issues/141 for details.

  • assert not text

    Confirm that the text of an element does not contain the provided value. The test will stop if the assert fails.

    arguments

  • locator : An element locator.

  • text : An exact string match. Support for pattern matching is in the works. See https://github.com/SeleniumHQ/selenium-ide/issues/141 for details.

  • assert prompt

    Confirm that a JavaScript prompt has been rendered. The test will stop if the assert fails.

    arguments

  • text : The text to use.
  • assert selected value

    Confirm that the value attribute of the selected option in a dropdown element contains the provided value. The test will stop if the assert fails.

    arguments

  • select locator : An element locator identifying a drop-down menu.

  • text : An exact string match. Support for pattern matching is in the works. See https://github.com/SeleniumHQ/selenium-ide/issues/141 for details.

  • assert selected label

    Confirm that the label of the selected option in a dropdown element contains the provided value. The test will stop if the assert fails.

    arguments

  • select locator : An element locator identifying a drop-down menu.

  • text : An exact string match. Support for pattern matching is in the works. See https://github.com/SeleniumHQ/selenium-ide/issues/141 for details.

  • assert text

    Confirm that the text of an element contains the provided value. The test will stop if the assert fails.

    arguments

  • locator : An element locator.

  • text : An exact string match. Support for pattern matching is in the works. See https://github.com/SeleniumHQ/selenium-ide/issues/141 for details.

  • 目录assert系列简介相关方法官方API验证过程小结assert系列简介使用断言,测试用例将会在断言失败后停止运行优点:可以直接直接了当的看到检查是否通过缺点:若检查失败,后续的检查不会被执行,无法收集检查的结果状态相关方法assertassert alertassert checkedassert confirmationassert editableassert element presentassert element not present. Selenium 工具专门为WEB应用程序编写的一个验收测试工具。 Selenium 的核心:browser bot,是用JAVASCRIPT编写的。 Selenium 工具有4种: Selenium IDE , Selenium Control, Selenium Core 这儿我们主要总结了 Selenium - IDE 工具 Selenium - IDE 只限于firefox浏览器中... 自动化测试 中寻找元素并进行操作,如果在元素好找的情况下,相信大家都可以较熟练地编写用例脚本了,但光进行操作可能还不够,有时候也需要对预期结果进行判断。 这里介绍几个常用断言的使用方法,可以一定程度上帮助大家对预期结果进行判断。 这里介绍以下几个断言方法: assert Equal assert NotEqual assert True assert False assert IsNone...
    # assert Equal(a,b,msg=None) 检查a==b,不等则报错 # assert NotEqual(a,b,msg=None) 检查a!=b,相等则报错 # assert In(a,b,msg=None) 检查a in b,不在报错 # assert NotIn(a,b,msg=None) 检查a not in b,在报错 # assert True(a,msg=None) 检查表达式a成立,不成立报错 # assert False(a,msg=None) 检查表达式a不成立,成立报错   做UI 自动化测试 ,经常要用到的方法就是——断言。断言主要目的是验证程序是否与预期结果一致,这样我们在程序运行完后知道哪些成功了,哪些失败了。   断言一般分两种,一种是程序运行到断言处异常,程序终止。另一种是程序运行到断言处异常,程序继续往下执行。第二种优于第一种是因为我们可以在日志中看到错误信息,并且对程序整个执行过程有一定的了解。   断言四种模式五种手段   测试用例...
    在编写 自动化测试 脚本时,为了使“机器”去自动辨识test case的执行结果是True还是False,一般都需要在用例执行过程中获取一些信息,来判断用例的执行时成功还是失败。 判断成功失败与否,就涉及到断言。webdriver的断言使用有三种模式:操作(action)、辅助(accessors)、断言( assert ion)。 1、操作(action) 模拟用户与Web应用程序的交互,一...
    我们通过WebDriver编写的 自动化测试 脚本,严格来说还不能称之为测试用例 ,主要是因为我们没有对测试的结果进行验证,通过 Assert 断言 比较期望值和实际值是否相同可以达到我们验证结果的目的 常见 Assert 断言方法: public class Test Assert { @Test public void test Assert ()
    elenium提供了三种模式的断言: assert 、verify、waitfor 1) Assert (断言) 失败时,该测试将终止。 2)Verify(验证) 失败时,该测试将继续执行,并将错误记入日志显示屏 3)Waitfor(等待) 用于等待某些条件变为真 如果该条件为真,他们将立即成功执行。如果该条件不为真,则将失败并暂停测试。直到超过当前所设定的超过时间。一般跟setTimeout...
    测试中断言的重要性 一、断言的作用: 1.断言也就是检查点,重在判断我们通过页面得出来的值与期望值是否相等,如果相等,则代表断言成功,程序会继续往下执行,如果不相等,则代表断言失败,程序就会在断言失败处中止。 二、断言的API: 1. Assert . assert Equals 2. Assert . assert False(condition) 3. Assert ....