Reputation: 24287
I have this snippet that returns an ElementFinder
const elem = $('[formatcontrolname="startDate"]').$('input');
I want to set the attribute ng-reflect-model
on this element.
Advice for doing this?
I've tried a few browser.executeScript
commands, but I can't figure out how to leverage the variable elem
.
Edit: I did not end up going this route. I was able to do what I needed using standard css selectors in protractor.
Upvotes: 0
Views: 4437
Reputation: 439
I set the value of date attribute by following:
browser.driver.executeScript("document.getElementById('start-date').setAttribute('value','01/10/2017')");
Try this in your scenario, hope this might help.
Upvotes: 2
Reputation: 14287
You shouldn't be doing this, this is not what a normal user would do when they are interacting with your app. I'll try to answer the second part of your question
I've tried a few browser.executeScript commands, but I can't figure out how to leverage the variable elem.
var el = element(by.module('header'));
var tag = browser.executeScript('return arguments[0].tagName', el);
Copied straight from here
Upvotes: 2