Closed masterjg closed 3 years ago
Sorry, we don't have a way to register custom locators :( Probably after a hard refactoring, we would provide a way to do it
Well that's too bad... Um, how do I select then by text (I know that I can do that by xpath, but that sounds more like a hack)? I thought that cssContainingText locator would work, but that too throws errors:
I.click({ cssContainingText: "English" });
No element found using locator: by.cssContainingText("English", "undefined")
I expect codeception to call cssContainingText(cssSelector, searchText)
Well, you can easily generate such locator using XPath (it's not a hack). I'd suggest to make a function to create such locators
function el_contains(el, text) {
return `//${el}[contains(., ${text})]`;
}
// usage
el_contains('h2', 'hello');
What are you trying to achieve?
I'm trying to add new custom locator.
What do you get instead?
WebDriverError: unknown error: by is not defined (Session info: chrome=60.0.3112.78) (Driver info: chromedriver=2.32.498513 (2c63aa53b2c658de596ed550eb5267ec5967b351),platform=Linux 4.8.0-59-generic x86_64)
Provide test source code if related
Here is my custom helper to sort of add custom locator. I think there should be a better way to register new locators?
Details