Selenium frame (String) is a method that uses the value of a name or id attribute. The purpose is to switch to a frame or iframe. If a switch does not occur then an exception / failure shows up in our Test Script. Watch how to switch to a frame using a String.
Here’s a list of all 3 Selenium Methods that help us Switch To A Frame.
1. frame(WebElement) = [ Ссылка ]
2. frame(String) = [ Ссылка ]
3. frame(index)
► View All Videos On LinkedIn = [ Ссылка ]
► View All Videos On YouTube (Caption and Non-Caption) = [ Ссылка ]
► View All Videos On Facebook (Caption and Non-Caption) = [ Ссылка ]
► Download Transcript, Presentation, and Source Code = [ Ссылка ]
► View Transcript, Presentation, and Source Code via github = [ Ссылка ]
► Free Selenium PDF Book: [ Ссылка ]
► Free Java PDF Book: [ Ссылка ]
► All Paperback & eBooks: [ Ссылка ]
► Increase Video Quality: Settings - Quality - Select HD
► CC Font Size: Settings - Subtitles/CC - Options - Font Size
► Turn CC On or Off: Click CC
► Transcript
Next, is frame using (String) which selects a frame by its name or id.
Let’s walkthrough the Application Under Test (AUT). First, we are going to load Chase then add a wait statement for this Welcome box. Finally, we enter a username. Go to Eclipse
The Method Name is switchToFrames_String. Let’s the load application driver.get(“[ Ссылка ]). Next, we find the Username element driver.findElement By id sendKeys @Test3400. Inspect the element.
Copy the value for id. Paste the value, add a Wait Statement before entering the Username, a dynamic explicit wait for 5 seconds. Next wait until userId-input-field is visible then run. There’s no information in the Username text field. There’s no information because the Welcome Sign In box has View Frame Source. View Frame Source indicates this box is a frame or iframe. Let’s inspect. Scroll up to iframe tag.
In addition, to the src attribute, notice the iframe has an id and name attribute with a value of logonbox. The previous switch example used a value within src but we are going to use logonbox for name and id. Let’s go back to Eclipse and perform our switch. As expected, we see a failure. This time, let’s use a String for switching. driver.switchTo.frame (String)
The description shows select a frame by its name or ID. Frames located by matching name attributes are always given precedence over those matched by ID. This means, we can use the name attribute or id attribute but name ranks higher than id. However, the iframe we are switching to has the same name and id. Therefore, it does not apply for this scenario.
Add logongbox within double quotes then run. This time username has information and switchToFrames_String Passed. That’s it and Thank You for watching Switch to a frame using String. Next, is switch to a frame using index.
#SeleniumTraining #SeleniumAutomation #BeginnerSeleniumTutorials #SeleniumWebDriver
Ещё видео!