Debomita Bhattacharjee

Debomita Bhattacharjee

590 Articles Published

Articles by Debomita Bhattacharjee

Page 51 of 59

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

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 29-Jul-2020 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
Debomita Bhattacharjee
Updated on 29-Jul-2020 223 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 handle frames in Selenium with python?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 29-Jul-2020 10K+ 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
Debomita Bhattacharjee
Updated on 29-Jul-2020 4K+ 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

How to extract text from a Javascript alert in Selenium with python?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 29-Jul-2020 897 Views

We can extract text from a Javascript alert with the help of text method under Alert class. The alerts are basically the browser popups that are triggered for either dismissing or accepting the data entered.All these actions are performed by Selenium with the help of class selenium.webdriver.common.alert.Alert(driver). It has the methods to extract the text on a particular alert, accepting and dismissing these pop ups of the browser.The elements on the alert cannot be identified by simply spying them from the html code. This is because these are considered implemented by Javascript.Selenium alert methods are listed below −accept() – This ...

Read More

How will you deselect an option from a static dropdown?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 29-Jul-2020 2K+ Views

We can deselect an option from a static dropdown with the help of methods under Select class.The deselect methods are listed below −deselect_by_value(args) − Deselection with the help of value of option.This method deselects the option based on the value of the specific option. NoSuchElementException thrown if there is no value which matches with the value given in the argument.Syntax −d = Select(driver.find_element_by_id("selection")) d.deselect_by_value('Selenium')deselect_by_index(args) − Deselection with the help of index of option.This method deselects the option based on the index of the specific option. The index of the elements mostly start with 0. NoSuchElementException thrown if there is no ...

Read More

How to select a radio button in a page in Selenium with python?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 29-Jul-2020 6K+ Views

We can select a radio in a page in Selenium with the help of click() method. First of all we need to uniquely identify the checkbox with the help of any of the locators like css, xpath, id, class and so on.Next we have to use findElement() method to locate the element and finally perform the clicking action. The exception will be thrown if there is no matching element found on the page.Syntaxdriver.find_element_by_xpath("//input[@name='radio-button']")ExampleCode Implementation for radio button selection.from selenium import webdriver #browser exposes an executable file #Through Selenium test we will invoke the executable file which will then #invoke actual ...

Read More

How to check a checkbox in a page in Selenium with python?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 29-Jul-2020 8K+ Views

We can check a checkbox in a page in Selenium with the help of click() method. First of all we need to uniquely identify the checkbox with the help of any of the locators like css, xpath, id, class and so on.Next we have to use findElement() method to locate the element and finally perform the clicking action. The exception will be thrown if there is no matching element found on the page.Syntaxdriver.find_element_by_xpath("//input[@name='check-box']")ExampleCode Implementation for checkbox selection.from selenium import webdriver #browser exposes an executable file #Through Selenium test we will invoke the executable file which will then #invoke actual browser ...

Read More

How to count the total number of radio buttons in a page in Selenium with python?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 29-Jul-2020 1K+ Views

We can count the total number of radio buttons in a page in Selenium with the help of find_elements method. While working on any radio buttons, we will always find an attribute type in the html code and its value should be radio.This characteristic is only applicable to radio buttons 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 attribute type = 'radio', we will use find_elements_by_xpath() method. This method returns a list of web elements with the type of xpath specified in the method ...

Read More

How to count the number of checkboxes in a page in Selenium with python?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 29-Jul-2020 2K+ Views

We can count the total number of checkboxes in a page in Selenium with the help of find_elements method. While working on any checkboxes, we will always find an attribute type in the html code and its value should be checkbox.This characteristic is only applicable to checkboxes 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 attribute type = 'checkbox', we will use find_elements_by_xpath() method. This method returns a list of web elements with the type of xpath specified in the method argument. In case ...

Read More
Showing 501–510 of 590 articles
« Prev 1 49 50 51 52 53 59 Next »
Advertisements