@@ -293,187 +293,36 @@ Scenario('validate all elements meet criteria', async ({ I }) => {
293293
294294## WebElement API
295295
296- Elements passed to your callbacks are wrapped in a ` WebElement ` class that provides a consistent API across all helpers. This ensures your element-based tests work the same way whether you're using Playwright, WebDriver, or Puppeteer .
296+ Elements passed to your callbacks are wrapped in a ` WebElement ` class that provides a consistent API across all helpers. For complete documentation of the WebElement API, see [ WebElement ] ( WebElement.md ) .
297297
298- ### Getting Element Information
299-
300- #### ` getText() `
301-
302- Get the visible text content of an element.
298+ Quick reference of available methods:
303299
304300``` js
305- await element (' .status' , async el => {
301+ await element (' .my-element' , async el => {
302+ // Get element information
306303 const text = await el .getText ()
307- console .log (text) // "Active"
308- })
309- ```
310-
311- #### ` getAttribute(name) `
312-
313- Get the value of an attribute.
314-
315- ``` js
316- await element (' input' , async el => {
317- const type = await el .getAttribute (' type' )
318- const placeholder = await el .getAttribute (' placeholder' )
319- })
320- ```
321-
322- #### ` getProperty(name) `
323-
324- Get the value of a JavaScript property.
325-
326- ``` js
327- await element (' input' , async el => {
328- const value = await el .getProperty (' value' )
329- const checked = await el .getProperty (' checked' )
330- })
331- ```
332-
333- #### ` getInnerHTML() `
334-
335- Get the inner HTML of an element.
336-
337- ``` js
338- await element (' .content' , async el => {
304+ const attr = await el .getAttribute (' data-value' )
305+ const prop = await el .getProperty (' value' )
339306 const html = await el .getInnerHTML ()
340- })
341- ```
342307
343- #### ` getValue() `
344-
345- Get the current value of an input element.
346-
347- ``` js
348- await element (' #username' , async el => {
349- const value = await el .getValue ()
350- })
351- ```
352-
353- ### Checking Element State
354-
355- #### ` isVisible() `
356-
357- Check if an element is visible.
358-
359- ``` js
360- await element (' .modal' , async el => {
308+ // Check state
361309 const visible = await el .isVisible ()
362- if (visible) {
363- console .log (' Modal is shown' )
364- }
365- })
366- ```
367-
368- #### ` isEnabled() `
369-
370- Check if an element is enabled (typically for inputs and buttons).
371-
372- ``` js
373- await element (' button' , async el => {
374310 const enabled = await el .isEnabled ()
375- if (! enabled) {
376- throw new Error (' Button should be enabled' )
377- }
378- })
379- ```
380-
381- #### ` exists() `
382-
383- Check if an element exists in the DOM.
384-
385- ``` js
386- await element (' .notification' , async el => {
387311 const exists = await el .exists ()
388- })
389- ```
390-
391- ### Element Interactions
392-
393- #### ` click(options) `
394312
395- Click the element.
396-
397- ``` js
398- await element (' .submit-btn' , async el => {
313+ // Interactions
399314 await el .click ()
400- } )
315+ await el . type ( ' text ' )
401316
402- // With options (Playwright/Puppeteer)
403- await element (' .btn' , async el => {
404- await el .click ({ button: ' right' })
405- })
406- ```
407-
408- #### ` type(text, options) `
317+ // Child elements
318+ const child = await el .$ (' .child' )
319+ const children = await el .$$ (' .child' )
409320
410- Type text into an input element.
411-
412- ``` js
413- await element (' #search' , async el => {
414- await el .type (' search query' )
415- })
416- ```
417-
418- ### Element Location
419-
420- #### ` getBoundingBox() `
421-
422- Get the position and size of an element.
423-
424- ``` js
425- await element (' .hero' , async el => {
321+ // Position
426322 const box = await el .getBoundingBox ()
427- console .log (` x: ${ box .x } , y: ${ box .y } , width: ${ box .width } , height: ${ box .height } ` )
428- })
429- ```
430-
431- ### Child Element Queries
432-
433- #### ` $(locator) `
434-
435- Find the first child element matching the locator.
436323
437- ``` js
438- await element (' .container' , async container => {
439- const button = await container .$ (' button' )
440- await button .click ()
441- })
442- ```
443-
444- #### ` $$(locator) `
445-
446- Find all child elements matching the locator.
447-
448- ``` js
449- await element (' .list' , async list => {
450- const items = await list .$$ (' .item' )
451- for (const item of items) {
452- console .log (await item .getText ())
453- }
454- })
455- ```
456-
457- ### Helper-Specific Methods
458-
459- #### ` getHelper() `
460-
461- Get the underlying helper instance.
462-
463- ``` js
464- await element (' .my-element' , async el => {
324+ // Native access
465325 const helper = el .getHelper ()
466- // Access helper-specific features if needed
467- })
468- ```
469-
470- #### ` getNativeElement() `
471-
472- Get the raw native element from the underlying browser library (Playwright ElementHandle, WebDriver WebElement, etc.).
473-
474- ``` js
475- await element (' .my-element' , async el => {
476326 const native = el .getNativeElement ()
477- // Use helper-specific APIs directly
478327})
479328```
0 commit comments