முக்கிய உள்ளடக்கத்திற்குச் செல்லவும்

தேர்வாளர்கள்

The WebDriver Protocol provides several selector strategies to query an element. WebdriverIO simplifies them to keep selecting elements simple. Please note that even though the command to query elements is called $ and $$, they have nothing to do with jQuery or the Sizzle Selector Engine.

While there are so many different selectors available, only a few of them provide a resilient way to find the right element. For example, given the following button:

<button
id="main"
class="btn btn-large"
name="submission"
role="button"
data-testid="submit"
>
Submit
</button>

We do and do not recommend the following selectors:

தேர்வாளர்பரிந்துரைக்கப்படுகிறதுகுறிப்புகள்
$('button')🚨 ஒருபோதும் இல்லைமோசமானது - மிகவும் பொதுவானது, சூழல் இல்லை.
$('.btn.btn-large')🚨 ஒருபோதும் இல்லைமோசம். ஸ்டைலிங்குடன் இணைந்துள்ளது. மாறுதலுக்கு மிகவும் உட்பட்டது.
$('#main')⚠️ சிறிதளவுசிறப்பானது. ஆனால் இன்னும் ஸ்டைலிங் அல்லது JS நிகழ்வு கேட்பவர்களுடன் இணைக்கப்பட்டுள்ளது.
$(() => document.queryElement('button'))⚠️ சிறிதளவுதிறம்பட வினவுகிறது, எழுத சிக்கலானது.
$('button[name="submission"]')⚠️ சிறிதளவுHTML சொற்பொருள் கொண்ட name பண்புக்கூறுடன் இணைக்கப்பட்டுள்ளது.
$('button[data-testid="submit"]')✅ நல்லதுகூடுதல் பண்புக்கூறு தேவை, a11y உடன் இணைக்கப்படவில்லை.
$('aria/Submit')✅ நல்லதுநல்லது. பயனர் பக்கத்துடன் எவ்வாறு தொடர்புகொள்கிறார் என்பதைப் போன்றது. மொழிபெயர்ப்புகள் புதுப்பிக்கப்படும்போது உங்கள் சோதனைகள் உடைந்து போகாமல் இருக்க மொழிபெயர்ப்பு கோப்புகளைப் பயன்படுத்த பரிந்துரைக்கப்படுகிறது. குறிப்பு: பெரிய பக்கங்களில் இந்த தேர்வாளர் மற்றவற்றைவிட மெதுவாக இருக்கலாம்.
$('button=Submit')✅ எப்போதும்சிறந்தது. பயனர் பக்கத்துடன் எவ்வாறு தொடர்புகொள்கிறார் என்பதைப் போன்றது மற்றும் விரைவானது. மொழிபெயர்ப்புகள் புதுப்பிக்கப்படும்போது உங்கள் சோதனைகள் உடைந்து போகாமல் இருக்க மொழிபெயர்ப்பு கோப்புகளைப் பயன்படுத்த பரிந்துரைக்கப்படுகிறது.

CSS Query Selector

If not indicated otherwise, WebdriverIO will query elements using the CSS selector pattern, e.g.:

selectors/example.js
loading...

To get an anchor element with a specific text in it, query the text starting with an equals (=) sign.

For example:

selectors/example.html
loading...

You can query this element by calling:

selectors/example.js
loading...