Found 455 Articles for Software Testing

What are the differences between current_window_handle and window_handles methods in Selenium with python?

Debomita Bhattacharjee
Updated on 29-Jul-2020 09:43:57

835 Views

There are differences between current_window_handle and window_handles methods in Selenium. Both are methods to handle multiple windows. They differences are listed below −current_window_handleThis method fetches the handle of the present window. Thus it deals with the window in focus at the moment. It returns the window handle id as a string value.Syntax −driver.current_window_handlewindow_handlesThis method fetches all the handle ids of the windows that are currently open. The collection of window handle ids is returned as a set data structure.Syntax −driver.window_handles w = driver.window_handles[2]The above code gives the handle id of the second window open in the present session.ExampleCode Implementation with ... Read More

What are the differences between switch_to_default_content() and switch_to.parent_frame() methods in Selenium with python?

Debomita Bhattacharjee
Updated on 29-Jul-2020 09:42:26

3K+ Views

There are differences between switch_to.parent_frame() and switch_to_default_content() in frames. They are listed below −switch_to_parent_frame()This method is used to come out of the present frame, then we can access the elements outside that frame and not inside of that frame. Thus the control is switched; the outer part may be another frame or part of the web page. So we are able to come out of the current frame.Syntax −driver.switch_to.parent_frame();switch_to_default_content()This method is used to come out of all the frames and switch the focus at the page. Once we move out, it loses the access to the elements inside the frames ... Read More

How to work with cookies in Selenium with python?

Debomita Bhattacharjee
Updated on 29-Jul-2020 09:39:16

662 Views

We can work with cookies in Selenium with the help of numerous methods which control the browser or its sessions. We can easily add or delete a cookie. A cookie implementation is essential for ensuring proper authentication of websites.The methods to work with cookie are listed below −add_cookie(args)This method adds a cookie to the present session. The arguments consist of the names of the cookies that we want to add.Syntax −driver.add_cookie({'id' : 'val' : 'session'})get_cookie(args)This method gets a cookie of a specific name. The argument consists of the name of the cookie that we want to retrieve.Syntax −driver.get_cookie("name")delete_cookie(args)This method deletes ... Read More

Describe some of the exceptions available in Selenium with python?

Debomita Bhattacharjee
Updated on 29-Jul-2020 09:38:11

323 Views

There are multiple exceptions available in Selenium that are thrown whenever any unexpected situations occur or any of the methods yield error. BaseException is the class from where all the objects of Python are derived.The exceptions that are generated by default are from the interpreter or the built in functions. The exceptions are generally created while we develop a new code and there is a good possibility of errors. Some of the exceptions of Selenium are listed below −ElementNotVisibleException – This exception is generated when an element is available in DOM, but it is invisible. Hence no actions can be ... Read More

How to find the status of an element in a page in Selenium with python?

Debomita Bhattacharjee
Updated on 29-Jul-2020 09:35:32

613 Views

We can find the status of an element in a page with the help of Selenium. We can get the information if an element is enabled or disabled. Also, we can verify if an element is visible on screen for the user interaction or not.On a web page, there may be numerous checkboxes or radio buttons. Selenium provides a method to check if these UI elements are in a selected state or not.There are multiple methods to verify the status of an element. They are listed below −is_selected()This method verifies whether an element (checkbox, radio button) is in selected condition ... Read More

What are the differences between close() and quit() methods in Selenium with python?

Debomita Bhattacharjee
Updated on 29-Jul-2020 09:31:55

2K+ Views

There may be situations when we need to open more than browsers with multiple tabs. In order to close these sessions quit() and close() methods are used in Selenium. However there are differences between them, they are listed below −The close() method can close the browser in focus. While quit() method works with the driver.dispose() method that closes every successive window.The close() method closes the present window on which we are working. While quit() method suspends all the driver sessions and instances, thereby closing each opened window.ExampleCode Implementation with close() method.from selenium import webdriver driver = webdriver.Chrome(executable_path="C:\chromedriver.exe") # to maximize ... Read More

What are the common driver methods that can be applied to browsers in Selenium with python?

Debomita Bhattacharjee
Updated on 29-Jul-2020 09:29:22

134 Views

There are multiple common web driver methods that allow operation on browsers in Selenium with Python. Some of these methods are listed below −driver.get(url)This method is used to navigate or launch a new URL. The webdriver waits until there is full page load. For an application that has AJAX code, the web driver remains unaware about complete loading of the page. Thus for these situations we need to use waits.driver.maximize_window()This method is used to maximize the active window that is interacting with the web driver.driver.minimize_window()This method is used to minimize the active window that is interacting with the web driver.driver.back()This ... Read More

How to count the total number of frames in Selenium with python?

Debomita Bhattacharjee
Updated on 29-Jul-2020 09:27:43

1K+ Views

We can count the total number of frames in a page in Selenium with the help of find_elements method. While working on frames, we will always find the tagname in the html code and its value should be frame/iframe.This characteristic is only applicable to frames on that particular page and to no other types of UI elements like edit box, link and so on.To retrieve all the elements with the tagname as frame or iframe we will use find_elements_by_tag_name() method. This method returns a list of web elements with the type of tagname specified in the method argument. In case ... Read More

How to handle frames in Selenium with python?

Debomita Bhattacharjee
Updated on 29-Jul-2020 09:26:46

9K+ Views

We can handle frames in Selenium. A frame is an HTML element that keeps a document within another document in a page. HTML has the or tags for embedding a frame inside a document.There are multiple APIs available in Selenium to work with the frames. They are listed below −switch_to_frame(id)This method is used to identify a frame with the help of frame id and then switch the focus to that particular frame.Syntax −driver.switch_to_frame("frameid"), where frameid is the id attribute present under the frame/iframe tag in HTML.switch_to_frame(name)This method is used to identify a frame with the help of frame ... Read More

How to handle child windows in Selenium with python?

Debomita Bhattacharjee
Updated on 29-Jul-2020 09:25:25

3K+ Views

We can handle child windows or tabs in Selenium. While working with child windows, we need to always shift the browser focus to the child windows, then perform operation on them.By default, the focus remains on the first parent window. There are multiple methods available in Selenium which are listed below −current_window_handleThis method fetches the handle of the present window.Syntax −driver.current_window_handlewindow_handlesThis method fetches all the handle ids of the windows that are currently open.Syntax −driver.window_handles w = driver.window_handles[2]The above code gives the handle id of the second window opened in the present session.switch_to.window(args)This method switches the focus of Selenium to ... Read More

Advertisements