JS- Dropdown and Web Table data retrieve
Webtable:Using all,repeater,each
function getwebtableResults(){
element.all(by.repeater("result in memory")).each(function(item){
//chain locators
item.element(by.css("td:nth-child(3)")).getText().then(function(text){
console.log(text);
});
})
}
Get values of the dropdown and select the value .
element.all(by.tagName("option")).each(function(item){
item.getAttribute('value').then(function(values){
console.log(values);
})
describe('',function(){
function calculate(a,b,c){
element(by.model("first")).sendKeys(a);
element(by.model("second")).sendKeys(b);
element.all(by.tagName("option")).each(function(item){
item.getAttribute('value').then(function(values){
if(values==c){
item.click();
element(by.id('gobutton')).click();
}
});
});
}
function getwebtableResults(){
element.all(by.repeater("result in memory")).each(function(item){
//chain locators
item.element(by.css("td:nth-child(3)")).getText().then(function(text){
console.log(text);
});
})
}
it('',function(){
browser.get("http://juliemr.github.io/protractor-demo/");
calculate(12,13,'ADDITION');
calculate(12,13,'DIVISION');
//calculate(12,13,'MODULO');
calculate(12,13,'MULTIPLICATION');
calculate(12,13,'SUBTRACTION');
getwebtableResults();
})
})
Comments
Post a Comment