日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > java >内容正文

java

java 字段验证_Selenium-Gherkin-Java:验证必填字段上的文本

發布時間:2025/1/21 java 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java 字段验证_Selenium-Gherkin-Java:验证必填字段上的文本 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

簡短版:我有一個必填字段,顯示“此字段是必需的”的元素可以包含多個消息。我正在努力設置我的BDD功能步驟、頁面和步驟文件,以驗證是否顯示了正確的消息。

長版:

對Java/Selenium比較陌生,對這種BDD自動化測試的形式也比較陌生,但是我得到了這個框架,并且正在努力工作。我在一個場景中添加了一個步驟,因為有幾個領域是威脅性的,但這沒有被測試。

該網站這是為發展中,將有20多個地區版本為它,所以我盡量保持任何硬記錄到最低限度/

情景

Scenario: 'Do you want to Join an Existing Company?' is an optional radio button selection field which displays 'Company Account Number' and 'Company Name' fields if the 'Yes' option is selected and is defaulted to option 'No'

Given The user is on the Lite Registration page

Than The 'Do you want to Join an Existing Company' radio button selection field is displayed

And the default selection is 'No'

And 'Company Account Number' and 'Company Name' fields are displayed for selection 'Yes'

And A 'Join request' message is displayed for a selection of 'Yes'

And 'Company Account Number' is a numeric field with max 30 char

And 'Company Name' is an alphanumeric filed with max 60 char

And 'Company Account Number' and 'Company Name' are mandatory fields

問題是包含錯誤消息的元素(即“This field is required.”)也會顯示其他消息,因此我無法確認顯示錯誤的元素。

我一直在嘗試對該元素的assert和.getText命令執行某些操作,但是我要么在不應該的時候傳遞,要么由于斷言錯誤而忽略了該步驟。

@FindBy(css = "#accountNumber-error")

private WebElement JECAccountNumberCharError;

//Methods

public boolean Try1() {

String m = JECAccountNumberCharError.getText();

return m.equals("This field is required");

} here

Step文件的相關部分

@And("^'Company Account Number' and 'Company Name' are mandatory fields$")

public void companyAccountNumberAndCompanyNameAreMandatoryFields() throws Throwable {

Assert.assertTrue(liteRegistration_page.Try1());

}

在上述情況下,將忽略測試,并在輸出中出現斷言錯誤

> java.lang.AssertionError

at org.junit.Assert.fail(Assert.java:86)

at org.junit.Assert.assertTrue(Assert.java:41)

at org.junit.Assert.assertTrue(Assert.java:52)

at steps.registration.LiteRegistration_Steps.companyAccountNumberAndCompanyNameAreMandatoryFields(LiteRegistration_Steps.java:481)

at a?.And 'Company Account Number' and 'Company Name' are mandatory fields(Registration/LiteRegistration_FeildValidation.feature:78)

我是不是找錯了我要找的解決方案?我真的很感激你的幫忙

Company account number

This field is required.

總結

以上是生活随笔為你收集整理的java 字段验证_Selenium-Gherkin-Java:验证必填字段上的文本的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。