ai đã đi

selenium - Selenium 标识符的建议命名约定

In lại 作者:行者123 更新时间:2023-12-03 00:35:11 hai mươi bốn 4
mua khóa gpt4 Nike

我使用 selenium 页面对象模型来定义所有页面元素。我对元素命名所遵循的命名约定不太相信,并且感觉太长了。请对此提出建议。

@FindBy(xpath = "//tbody[@id='tabview:listComp1_data']/tr/td[1]/div/div[2]")
public WebElement tableCompanyResultsRow;

@FindBy(xpath = ".//*[@id='mttAddId']")
public WebElement buttonAddMap;

@FindBy(xpath = ".//*[@id='ittAddId']")
public WebElement buttonAddItinerary;

@FindBy(xpath = "//div[@id='ajaxStatusPanel_start']/img")
public WebElement imageLoading;

1 Câu trả lời

我长期以来一直使用以下命名约定,它有助于理解和区分 UI 元素。

对于定位器,我总是在变量名称前加上 loc_ 前缀。例如:loc_btnExit

+----------+----------------------------+--------+-----------------+| Category | UI/Control type | Prefix | Example |+----------+----------------------------+--------+-----------------+| Basic | Button | btn | btnExit || Basic | Check box | chk | chkReadOnly || Basic | Combo box | cbo | cboEnglish || Basic | Common dialog | dlg | dlgFileOpen || Basic | Date picker | dtp | dtpPublished || Basic | Dropdown List / Select tag | ddl | ddlCountry || Basic | Form | frm | frmEntry || Basic | Frame | fra | fraLanguage || Basic | Image | img | imgIcon || Basic | Label | lbl | lblHelpMessage || Basic | Links/Anchor Tags | lnk | lnkForgotPwd || Basic | List box | lst | lstPolicyCodes || Basic | Menu | mnu | mnuFileOpen || Basic | Radio button / group | rdo | rdoGender || Basic | RichTextBox | rtf | rtfReport || Basic | Table | tbl | tblCustomer || Basic | TabStrip | tab | tabOptions || Basic | Text Area | txa | txaDescription || Basic | Text box | txt | txtLastName || Complex | Chevron | chv | chvProtocol || Complex | Data grid | dgd | dgdTitles || Complex | Data list | dbl | dblPublisher || Complex | Directory list box | dir | dirSource || Complex | Drive list box | drv | drvTarget || Complex | File list box | fil | filSource || Complex | Panel/Fieldset | pnl | pnlGroup || Complex | ProgressBar | prg | prgLoadFile || Complex | Slider | sld | sldScale || Complex | Spinner | spn | spnPages || Complex | StatusBar | sta | staDateTime || Complex | Timer | tmr | tmrAlarm || Complex | Toolbar | tlb | tlbActions || Complex | TreeView | tre | treOrganization |+----------+----------------------------+--------+-----------------+

关于selenium - Selenium 标识符的建议命名约定,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45028747/

hai mươi bốn 4 0
Bài viết được đề xuất: ruby-on-rails - 如何使用 Puma 在 Heroku 上部署 Michael Hartl 的 Rails 教程应用程序
Bài viết được đề xuất: elasticsearch - 如何在术语查询中查询对象数组
Bài viết được đề xuất: powershell - Powershell if语句传递参数
Bài viết được đề xuất: WPF 字符串属性与 Button.Content 的绑定(bind)
行者123
Hồ sơ cá nhân

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá Didi Taxi miễn phí
Mã giảm giá Didi Taxi
Các bài viết nóng hổi trên toàn bộ trang web
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com