Skip to content

Conversation

rezaansari7
Copy link

Enhanced Scroll Commands with XPath Support

This PR adds enhanced scroll commands to Nightwatch with improved XPath selector support, making it easier to scroll to elements using various selector types.

Features Added

  • Enhanced scrollIntoView command with XPath support
  • Support for text-based XPath selectors (e.g., //*[contains(text(),"Some text")])
  • Automatic detection and handling of XPath vs CSS selectors
  • Smooth scrolling behavior options
  • Example test demonstrating various scroll commands

Changes

  • Added new scroll commands in lib/api/client-commands/scroll/
  • Added TypeScript definitions for new commands
  • Added example test file demonstrating usage
  • Added test files for scroll commands

Example Usage

browser
  // Scroll using ID selector
  .scrollIntoView({
    element: '#the-basics',
    behavior: 'smooth',
    block: 'center'
  })
  
  // Scroll using XPath text selector
  .scrollIntoView({
    element: '//*[contains(text(),"Super-powered")]',
    behavior: 'smooth',
    block: 'center'
  });

Testing

The changes have been tested with:

  • Different types of selectors (ID, XPath, CSS)
  • Text-based XPath selectors
  • Various scroll behaviors and options

All tests are passing and the implementation follows Nightwatch's coding standards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant