My goal is to be able to interact with a user-provided CSS string using protractor, cucumber, and typescript. However, the code I have written does not seem to be effective in this scenario.
While element(by.id(x)) works perfectly, element(by.css(x)) does not yield the desired result.
Below is an excerpt from Steps.ts:
import { Given, Then, When } from '
import {$, browser, by, element} from 'protractor';
import { FacebookPage } from '../../page_objects/pages/facebook/facebook.page';
import { expect } from '../support/expect';
let page:
Then(/^waiting for (.*) seconds$/, function (wait): number {
browser.sleep(wait * 1000); //works fine but could you please provide a better solution?
});
Then(/^clicking on button with ID (.*)$/, async function (idOfElement){
await element(by.id(idOfElement)).click();
return true; //works perfectly
});
Then(/^clicking on button with CSS selector (.*)$/, async function (idOfElement){
return await element(by.css(idOfElement,)).click() //doesnt work at all
});
If needed, I can share the cucumber code and my protractor configuration, though I don't believe it's necessary at this point.
Error message: NoSuchElementError: No element found using locator: By(css selector, href="/messages/t/")
Another error message encountered: InvalidSelectorError: invalid selector: An invalid or illegal selector was specified
I am certain that there is a text with href="/messages/t/" present on the page