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

feat(elementFinder): keep a reference to the original locator #800

Closed
wants to merge 1 commit into from

Conversation

elgalu
Copy link
Contributor

@elgalu elgalu commented May 12, 2014

There are some reasons to expose the reference to the original webdriver.Locator, @Droogans for example shows one here

I personally need this because sometimes i find myself using webdriver directly, i.e. browser.driver.xxxx and for that reason i'm unable to use certain shortcuts like $('a.thing') within my page objects, using by.css('a.thing') then wrapping the locator with element() when needed.

Being able to do element(aThing).locator() will give the flexibility back.

@elgalu elgalu added cla: yes and removed cla: no labels May 12, 2014
var byBinding = by.binding('greet');
expect(byCss).toEqual(element(byCss).locator());
expect(byBinding).toEqual(element(byBinding).locator());
});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what I was expecting, I think I misunderstand the use case here. For some reason I was thinking something like this:

expect(by.css('body').locator()).toEqual('body');
expect(by.css('body').strategy()).toEqual(by.css);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea of returning the {webdriver.Locator} type is having all its original flexibility back:

$('body').locator(); //=>
{ using: 'css selector', value: 'body' }

element(by.model('username')).locator(); //=>
{ findElementsOverride: [Function],
  message: 'by.model("username")' }

@juliemr
Copy link
Member

juliemr commented May 17, 2014

Looks good. I would actually label this a feature since it's adding something to the API. I'll make the tiny change I mentioned and merge.

@juliemr
Copy link
Member

juliemr commented May 17, 2014

Merged as b93bf18

@juliemr juliemr closed this May 17, 2014
@elgalu elgalu changed the title chore(elementFinder): keep a reference to the original locator feat(elementFinder): keep a reference to the original locator May 21, 2014
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 this pull request may close these issues.

None yet

3 participants