Found 719 Articles for Testing Tools

How to close active/current tab without closing the browser in Selenium-Python?

Debomita Bhattacharjee
Updated on 06-Apr-2021 08:54:06

14K+ Views

We can close the active/current tab without closing the browser in Selenium webdriver in Python. By default, Selenium has control over the parent window. Once another browser window is opened, we have to explicitly shift the control with the help of switch_to.window method.The handle id of the browser window where we want to shift is passed as a parameter to that method. The method window_handles returns the list of all window handle ids of the opened browsers.The method current_window_handle is used to hold the window handle id of the browser window in focus. To close only the active or current ... Read More

What are the pre-conditions for Selenium Internet Explorer Driver or IE Driver?

Debomita Bhattacharjee
Updated on 06-Apr-2021 08:53:45

201 Views

There are pre-conditions to be configured before we can kick off execution in Selenium webdriver. First we have to check the Protection Mode of our IE browser.Launch Internet Explorer → move to Tools Menu → Internet Options.Then go to the Security tab. Check the option Select Enable Protected Mode. Also, we have to choose the Internet as the zone. We can make the level as Mediumhigh.The other Protection zones like Local Intranet and Trusted sites (apart from Restricted sites) should also have the same configuration. Once all the configurations are done, we have to Apply and then click OK.After above ... Read More

How to configure IE Driver via System Properties in Environment Variables?

Debomita Bhattacharjee
Updated on 06-Apr-2021 08:48:51

318 Views

We can configure IE Driver via System Properties in Environment variables. Firstly, we have to navigate to the link − https://www.selenium.dev/downloads/. Then click on the download link (32 or 64 it) based on the operating system available with us.Once the download is done, a zip file gets created. It needs to be extracted and saved in a location. After the file is extracted, the executable file - IEDriverServer.exe becomes available.Enter environment variables from the Start. Then click on Edit the system environment variables as shown on the below image.Navigate to the Advanced tab in the System Properties pop-up. Then click ... Read More

How to find an element using the “CSS Selector” in Selenium?

Debomita Bhattacharjee
Updated on 06-Apr-2021 08:44:38

5K+ Views

We can find an element using the css locator with Selenium webdriver. To identify the element with css, the expression should be tagname[attribute='value'].We can also specifically use the id attribute to create a css expression.With id, the format of a css expression should be tagname#. For example, input#txt [here input is the tagname and the txt is the value of the id attribute].With class, the format of css expression should be tagname. . For example, input.cls-txt [here input is the tagname and the cls-txt is the value of the class attribute].If there are n children of a parent element, and ... Read More

How to find an element using the “XPath” in Selenium?

Debomita Bhattacharjee
Updated on 06-Apr-2021 08:44:11

7K+ Views

We can find an element using the xpath locator with Selenium webdriver.To identify the element with xpath, the expression should be //tagname[@attribute='value'].To identify the element with xpath, the expression should be //tagname[@class='value']. There can be two types of xpath – relative and absolute. The absolute xpath begins with / symbol and starts from the root node upto the element that we want to identify.For example, /html/body/div[1]/div/div[1]/aThe relative xpath begins with // symbol and does not start from the root node. For example, //img[@alt='tutorialspoint']Let us see the html code of the highlighted element starting from the root.The absolute xpath for the ... Read More

What is the exact meaning of webdriver.chrome.driver and where this system property is located in Selenium?

Debomita Bhattacharjee
Updated on 06-Apr-2021 08:43:32

4K+ Views

To launch the Chrome browser, we have to use the System.setProperty method. This method takes the parameters – webdriver.chrome.driver and the path of the chromedriver.exe file.So webdriver.chrome.driver is basically the property name and the path of the chromedriver.exe is the value. Thus, the System.setProperty method is used to configure the browser driver path.The Selenium client library communicates with the ChromeDriver via the JSON Wire Protocol. The Chrome browser driver acts like a link between the Selenium implementation code and the Chrome browser. The System.setProperty is the beginning line that requires to be added to our test prior creation of webdriver ... Read More

How to switch different browser tabs using Python Selenium?

Debomita Bhattacharjee
Updated on 06-Apr-2021 08:39:11

6K+ Views

We can switch different browser tabs using Selenium webdriver in Python using the method switch_to.window. By default, the webdriver has access to the parent window.Once another browser tab is opened, the switch_to.window helps to switch the webdriver focus to the tab. The window handle of the browser window where we want to shift is passed as a parameter to that method.The method window_handles contains the list of all window handle ids of the opened browsers. The method current_window_handle is used to hold the window handle id of the browser window in focus.Syntaxp = driver.current_window_handle parent = driver.window_handles[0] chld = driver.window_handles[1] ... Read More

How to switch back from a frame to default in Selenium Webdriver?

Debomita Bhattacharjee
Updated on 06-Apr-2021 08:35:15

7K+ Views

We can switch back from a frame to default in Selenium webdriver using the switchTo().defaultContent() method. Initially, the webdriver control remains on the main web page.In order to access elements within the frame, we have to shift the control from the main page to the frame with the help of the switchTo().frame and pass the frame name/id or webelement of the frame as a parameter to that method.Finally, again we can switch the control to the main page with the switchTo().defaultContent() method. A frame is identified in the html code with the tag names – frame, iframe or frameset.Let us ... Read More

How to know the exact time to load a page using Selenium WebDriver?

Debomita Bhattacharjee
Updated on 06-Apr-2021 08:34:09

4K+ Views

We can determine the exact time to load a page using Selenium webdriver. We can capture the time before the page load with help of the System.currentTimeMillis method.After the URL for the application is launched, we have to wait for the page to be loaded completely with the help of the explicit wait condition. Once the expected criteria for the element is met, we shall again record the current time.The difference between the time recorded prior and post the page load will measure the exact time to load a page.Syntaxlong s = System.currentTimeMillis();Exampleimport org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; ... Read More

How to use relative xpath for locating a web-element by particular Attribute in Selenium?

Debomita Bhattacharjee
Updated on 06-Apr-2021 08:30:56

1K+ Views

We can use relative xpath for locating web-element by particular attribute value. A relative xpath begins from the element to be located and not from the root.It begins with the // symbol. It’s advantage is that even if an element is deleted or added in the DOM, the relative xpath for a specific element remains unaffected. To obtain a relative path by an attribute, the xpath expression is //tagname[@attribute='value'].Let us identify the below highlighted element on the page with the help of the alt attribute.Syntaxl = driver.find_element_by_xpath("//img[@alt='tutorialspoint']")Examplefrom selenium import webdriver #set chromodriver.exe path driver = webdriver.Chrome(executable_path="C:\chromedriver.exe") driver.implicitly_wait(0.5) #launch URL driver.get("https://www.tutorialspoint.com/about/about_careers.htm") ... Read More

Advertisements