Created
June 18, 2020 15:09
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// import all the required modules from selenium web driver and protractor to handle frames in Selenium | |
import { browser, element, by, ExpectedConditions, protractor} from 'protractor' | |
import { Alert, WebElement } from 'selenium-webdriver'; | |
// describing the test for the frame demonstration // | |
describe(' Frame Demonstration in Protractor ', function() { | |
browser.ignoreSynchronization = true; // disable synchronization for non angular websites // | |
// tests to handle default content in protractor // | |
it(' Tests to handle default content in protractor ', function() { | |
browser.manage().timeouts().implicitlyWait(5000) | |
// launch the url in the browser // | |
browser.get("http://the-internet.herokuapp.com/nested_frames "); | |
//find the frame1 and store it in web element | |
WebElement frame1 = element(by.id("frame1")).getWebElement(); | |
// navigate to the frame1 | |
browser.switchTo().frame(frame1); | |
// navigate to the frame 3 | |
WebElement frame3 = element(by.xpath("//iframe[@id='frame3']")).getWebElement(); | |
// navigate to frame 3 | |
browser.switchTo().frame(frame3); | |
// search for the checkbox | |
WebElement checkbox = element(by.xpath("//input[@type='checkbox']")); | |
// verify whether the checkbox is selected else selected the checkbox by clicking it // | |
checkbox.isSelected().then(function(checked){ | |
//or perform many other operation to validate the change in frame. | |
if(! checked){ | |
checkbox.click(); | |
} | |
}) | |
// switch to the page default content | |
browser.switchTo().defaultContent(); | |
// navigate to the new frame using the switch to frame method // | |
browser.switchTo().frame("frame2"); | |
// search the tag from the drop down element // | |
element(by.tagName("select")).click() | |
// select the value from the drop down option // | |
element(by.xpath("//option[text()='Avatar']")).click() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment