Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get css selector string from protractor's ElementFinder

I want to create a generic function that notifies on errors

I can't seem to find a way to get the css selector from an ElementFinder member

Here's my function:

static waitForElementToExist(elementFinder: ElementFinder): SeleniumPromise<any> {
    return browser.wait(until.presenceOf(elementFinder),
        jasmine.DEFAULT_TIMEOUT_INTERVAL,
        MyErrors.elementNotFound(<get element selector string>));
};

so I can return a meaningful error like:

could not found the element '.class-selector'

can anyone point me to the right direction please? :-)

like image 904
Thatkookooguy Avatar asked May 03 '26 09:05

Thatkookooguy


1 Answers

If you use latest protractor, try:

MyErrors.elementNotFound(elementFinder.locator().toString())

More detail, please look locator() api.

like image 192
yong Avatar answered May 05 '26 22:05

yong



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!