Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Locator build is failing on hyphen in css class names eg locate('a').find('.n-a') #3563

Closed
nikocanvacom opened this issue Jan 6, 2023 · 1 comment · Fixed by #4024
Closed
Labels

Comments

@nikocanvacom
Copy link
Contributor

nikocanvacom commented Jan 6, 2023

What are you trying to achieve?

Use CodecepJS locate builder for managing of hierarchical elements as PageObject in a web testing framework for application with obfuscated(hashed) frontend class names where simplified code of subelement locator building could look like following:

locate('a').find('.n-a')

What do you get instead?

Exception on locate('a').find('.n-a')

-- FAILURES:

  1) Web test playground
       simple web test:
     Error: Parse error on line 1:
.n-a
--^
Expecting 'EOF', ',', 'S', '>', '.', '#', '[', ']', '=', 'CONTAINS', 'DOES_NOT_CONTAIN', 'CONTAINS_WORD', 'CONTAINS_PREFIX', 'STARTS_WITH', 'ENDS_WITH', '~', '+', ':', 'ODD_ARGUMENT', 'EVEN_ARGUMENT', '(', ')', got '-'
      at Parser.parseError (node_modules/bo-selector/parser.js:204:15)
      at Parser.parse (node_modules/bo-selector/parser.js:262:22)
      at parse (node_modules/css-to-xpath/js/css_to_xpath.js:12:23)
      at convertToXpath (node_modules/css-to-xpath/js/css_to_xpath.js:15:16)
      at Locator.toXPath (node_modules/codeceptjs/lib/locator.js:165:30)
      at convertToSubSelector (node_modules/codeceptjs/lib/locator.js:509:47)
      at Locator.find (node_modules/codeceptjs/lib/locator.js:188:53)
      at Test.<anonymous> (tests/example-web-test.ts:11:17)
      at Context.test.fn (node_modules/codeceptjs/lib/scenario.js:78:14)

or on locate('a').find('.n-6a')

-- FAILURES:

  1) Web test playground
       simple web test:
     Error: Parse error on line 1:
.n-6a
--^
Expecting 'EOF', ',', 'S', '>', '.', '#', '[', ']', '=', 'CONTAINS', 'DOES_NOT_CONTAIN', 'CONTAINS_WORD', 'CONTAINS_PREFIX', 'STARTS_WITH', 'ENDS_WITH', '~', '+', ':', 'ODD_ARGUMENT', 'EVEN_ARGUMENT', '(', ')', got 'NEGATIVE_INTEGER'
      at Parser.parseError (node_modules/bo-selector/parser.js:204:15)
      at Parser.parse (node_modules/bo-selector/parser.js:262:22)
      at parse (node_modules/css-to-xpath/js/css_to_xpath.js:12:23)
      at convertToXpath (node_modules/css-to-xpath/js/css_to_xpath.js:15:16)
      at Locator.toXPath (node_modules/codeceptjs/lib/locator.js:165:30)
      at convertToSubSelector (node_modules/codeceptjs/lib/locator.js:509:47)
      at Locator.find (node_modules/codeceptjs/lib/locator.js:188:53)
      at Test.<anonymous> (tests/example-web-test.ts:11:17)
      at Context.test.fn (node_modules/codeceptjs/lib/scenario.js:78:14)

Provide test source code if related

Feature('Web test playground');

Scenario('simple web test', async ({ I }) => {
    locate('a').find('.n-6a');
});

Details

  • CodeceptJS version: 3.3.7
  • NodeJS Version: 14.21.2
  • Operating System:
  • puppeteer || webdriverio || testcafe version (if related)
  • Configuration file:
require('ts-node/register')
const { setHeadlessWhen } = require('@codeceptjs/configure');
const { bootstrap } = require('./presettings.ts');

exports.config = {
  tests: './tests/**-web-test.ts',
  output: './output',
  helpers: {
    Playwright: {
      url: "http://localhost:9090/",
      restart: false,
      waitForNavigation: "networkidle0",
      waitForAction: 500
    }
  },
  bootstrap,
  name: 'c-csjs',
  }
}
@nikocanvacom nikocanvacom changed the title Locator build is failing hyphen in class name eg locate('a').find('.n-a') Locator build is failing on hyphen in css class names eg locate('a').find('.n-a') Jan 6, 2023
@github-actions
Copy link

This issue is stale because it has been open for 90 days with no activity.

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

Successfully merging a pull request may close this issue.

1 participant