Articles on Trending Technologies

Technical articles with clear explanations and examples

How to perform double click on an element in Selenium with python?

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

We can perform double click on an element in Selenium with the help of Action Chains class. These classes are generally used for automating interactions like context menu click, mouse button actions, key press and mouse movements.These types of actions are mainly common in complex scenarios like drag and drop and hovering over an element on the page. The methods of the Action Chains class are utilized by advanced scripts. We can manipulate DOM with the help of Action Chains in Selenium.The action chain object implements the ActionChains in the form of a queue and then executes the perform() method. ...

Read More

How to perform drag and drop operation in Selenium with python?

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

We can perform drag and drop actions in Selenium with the help of Action Chains class. These classes are generally used for automating interactions like context menu click, mouse button actions, key press and mouse movements.These types of actions are mainly common in complex scenarios like drag and drop and hovering over an element on the page. The methods of the Action Chains class are utilized by advanced scripts. We can manipulate DOM with the help of Action Chains in Selenium.The action chain object implements the ActionChains in the form of a queue and then executes the perform() method. On ...

Read More

How to get the values of a particular row in a table in Selenium with python?

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

We can get the values of a particular row in a table in Selenium. The rows of a table are represented by tag in html code. The data in each row is enclosed with the tag in html. Thus a tag’s parent is always a tag.The logic is get all the rows, we shall use the locator xpath and then use find_elements_by_xpath method. The list of rows will be returned. Next we need to compute the size of the list with the help of len method.The is not normally present in the first row of ...

Read More

How to count the number of rows in a table in Selenium with python?

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

We can count the total number of rows in a table in Selenium. The rows of a table are represented by tag in html code. To get all the rows, we shall use the locator xpath and then use find_elements_by_xpath method. The list of rows will be returned. Next we need to compute the size of the list with the help of len method.The html code snippet of a table row count is as described below −Syntaxdriver.find_elements_by_xpath("//table/tbody/tr")ExampleCode Implementation for getting row count.from selenium import webdriver #browser exposes an executable file #Through Selenium test we will invoke the executable file ...

Read More

How to key in values in input text box with Javascript executor in Selenium with python?

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

We can key in values inside an input text box with a Javascript executor in Selenium. Javascript is a language used for scripting and runs on the client side (on the browser). Selenium gives default methods to work with Javascript.SyntaxjavaScript = "document.getElementsByClassName('gsc-input')[0].value = 'T' ") driver.execute_script(javaScript)There are couple of methods by which Javascript can be executed within browser −Javascript execution at document root level.In this process, we shall identify the element with locators (class or id) and then perform the required action on it. Then execute_script() method is called and the Javascript is passed as a string to it.Syntax −javas ...

Read More

How to click on a link with a Javascript executor in Selenium with python?

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

We can perform click operation on links with Javascript executors in Selenium. Javascript is a language used for scripting and runs on the client side (on the browser). Selenium gives default methods to work with Javascript.SyntaxjavaScript = "document.getElementsByClassName('tp-logo')[0].click();" driver.execute_script(javaScript)There are couple of methods by which Javascript can be executed within browser −Javascript execution at document root level.In this process, we shall identify the element with locators (class or id) and then perform the required action on it. Then execute_script() method is called and the Javascript is passed as a string to it.Syntax −javas = "document.getElementsByName('user-search')[0].click();" driver.execute_script(javas)Please note, we have used ...

Read More

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

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 29-Jul-2020 1K+ 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
Debomita Bhattacharjee
Updated on 29-Jul-2020 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
Debomita Bhattacharjee
Updated on 29-Jul-2020 806 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
Debomita Bhattacharjee
Updated on 29-Jul-2020 458 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
Showing 40181–40190 of 61,248 articles
Advertisements