Thatkookooguy
Thatkookooguy

Reputation: 7012

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? :-)

Upvotes: 3

Views: 594

Answers (1)

yong
yong

Reputation: 13712

If you use latest protractor, try:

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

More detail, please look locator() api.

Upvotes: 4

Related Questions