How to Find Elements and writing Test Case in Protractor - Bug Reaper

                  Bug Reaper

Lean about Automation Testing,Selenium WebDriver,RestAssured,Appium,Jenkins,JAVA,API Automation,TestNG,Maven, Rest API, SOAP API,Linux,Maven,Security Testing,Interview Questions

Friday, 11 September 2020

How to Find Elements and writing Test Case in Protractor

Finding Elements in Protractor

Protractor Exposes 2 global functions

element--> finds a single element
element.all--> finds  multiple elements

PomBuilder Extension on Chrome(This will help in finding locators)

Very Helpful: 
Refer below to write Test cases fast with shortcuts for Protractor Snippet



 First Test Case
Website used


describe('Test Sample App',function(){
    it('Launch',function(){
        browser.get('https://juliemr.github.io/protractor-demo/')
        let ele=element(by.model('first')) // defining one variable let, we can use let instead of var
        ele.click()
        ele.sendKeys(2)
        browser.sleep(5000)
      
        
        let ele1=element(by.model('second'))
        ele1.click()
        ele1.sendKeys(5)
        browser.sleep(5000)
        
        element(by.className('btn')).click()
        browser.sleep(5000)
       
       
        let text=element(by.className('ng-binding')).getText()
        expect(text).toBe('7') // expect comes from Jasmine 
    })
})

How protractor handles element before clicking on it

browser.waitForAngular (Instruct webdriver to wait until Angular has finished rendering and has no outstanding $http or $timeout calls before continuing. Note that Protractor automatically applies this command before every WebDriver action.)



No comments:

Post a Comment