Selenium Tutorial 21: Handling Elements in Selenium Part 3

preview_player
Показать описание
Handling Elements in Selenium Part 3 tutorial explains handling elements in Selenium WebDriver using Element locators and WebDriver methods. Handling Frames, Working with Multiple browsers, and handling duplicate elements. Creating Selenium Test cases using Element Locators, WebDriver methods and Java programming features.
Рекомендации по теме
Комментарии
Автор

After this level of guidance, there will be many Selenium testers available in the market. :)

anurag
Автор

Class Notes:
Selenium Class 21: Handling Elements in Selenium Part-3

In Handling Elements in Selenium Part-1

i) Handle Browser

ii) Handle Edit box

iii) Handle Text Area, Error Message, Window Dialog

iv) Handle Button

In Handling Elements in Selenium Part-2

v) Handle Images (General Image, Image Button and Image Link)

vi) Handle Link

vii) Handle Radio Button

viii) Handle Drop down box

ix) Handle Check box

x) Handle Web Table / HTML Table

xi) Handling inline Elements

Handling Elements in Selenium Part-3

xii) Handle Frames

> HTML frames are used to divide the Browser window into multiple sections, where each section can load a separate HTML document.

> Frames are sections of Web page displayed on top window.

> Whenever we access the page then focus on the top window.

Switch to a frame is done in two ways

1) Using frame index

Syntax:

driver.swithchTo().frame(int index);

Example:

driver.switchTo().frame(2);


2) Using frame name

Syntax:

frame Name);

Example:




> Top window to a Frame (frame index/frame name)

> Switch from a frame to Top window

Syntax:



> Launch the page
> Switch to 3rd frame
> Operate an element
> Back to Top window
> Switch to 1st frame
> Operate an element

WebDriver driver = new FirefoxDriver();

//Switch to 3rd frame
driver.switchTo().frame(2);

Thread.sleep(3000);
//Switch from 3rd frame to Top window

Thread.sleep(3000);
//Switch to 1st frame
driver.switchTo().frame(0);


WebDriver driver = new FirefoxDriver();
Thread.sleep(3000);
//Switch to 3rd frame


Thread.sleep(3000);
//Switch from 3rd frame to Top window

Thread.sleep(3000);
//Switch to 1st frame


}
}

xiii) Handle Mouse hover

WebDriver driver = new FirefoxDriver();
//create Action builder instance by passing WebDriver instance
Actions builder = new Actions(driver);
WebElement menuElement = Us Your Car"));



xiv) Handle Multiple Browsers

String parent = driver.getWindowHandle();
//System.out.println(parent);

Set <String> Handles = driver.getWindowHandles();
int BrowserCount = Handles.size();


for (String s1:Handles){
if (! s1.equals(parent)){
driver.switchTo().window(s1);

}
}



Handle Duplicate objects

Redirecting to GCR Shop User Interface from Admin Interface
(After Login to Admin Interface then Redirect to User Interface)

Example:



String url = driver.getCurrentUrl();
Catalog")).click();
}

}
}

Assignment:

Enter Password in to 2nd Password Edit box in www.infibeam.com Registration page.

gcreddy
Автор

Its really nice and useful session sir

prabakarm
Автор

Hi sir. very nice explanation. how to differentiate duplicate web elements if all the locators are same(given assignment in this course). I tried but able to access only first password option. Thanks in advance.

anilbabu
Автор

Hi sir..
Can you please give example for duplicate objects on same page. In my case, same screen having different web elements like text box, drop down with same all element locators (duplicate objects).
Thanks

anupraj
Автор

driver.get("URL") always opens the browser in a minimised mode. Any ides why?

juliemjacob
Автор

Where can I get the sample Webpages you have created in this lesson?

sahasra
Автор

xiv) Handling multiple browsers: In this section, do you mean 'multiple browser' or 'multiple window' ? because when the 'sign-in' button is clicked it opens second window but the browser is still 'Firefox'.

shailendrabhattarai
Автор

Sir what ever methods we are using in webdriver for example.select, click and many other methods are from Interface s.when an interface is 100% abstract..all these methods should be unimplemented methods then how r we using them to perform some operation...I mean ex:when we use click method it works..where are we implementing these methods.pls clarify

KrishnaPriya-rumo
Автор

how to get a links using for loop and they are checked all links

Exam
Автор

while doing the assignment

#password")).sendKeys("ddd");

But I am getting the Element is not currently visible and so may not be interacted with
Command duration or timeout: 29 milliseconds

Can you please help

whatishap
Автор

can we switch from one frame to another without switching to main window

ananthasainakkala
Автор

sir what is hidden elements ?how to find hidden elements

kumar-tkm
welcome to shbcf.ru