![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 871 Articles for Automation Testing
![Debomita Bhattacharjee](https://www.tutorialspoint.com/assets/profiles/210947/profile/60_171666-1594382095.jpg)
5K+ Views
We can wait until the page is completely loaded in Selenium webdriver by using the JavaScript Executor. Selenium can run JavaScript commands with the help of the executeScript method.We have to pass return document.readyState as a parameter to the executeScript method and then verify if the value returned by this command is complete.SyntaxJavascriptExecutor j = (JavascriptExecutor)driver; if (j.executeScript("return document.readyState").toString().equals("complete")){ System.out.println("Page has loaded"); }Exampleimport org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; import java.util.concurrent.TimeUnit; import org.openqa.selenium.JavascriptExecutor; public class PageLdWait{ public static void main(String[] args) { System.setProperty("webdriver.gecko.driver", "C:\Users\ghs6kor\Desktop\Java\geckodriver.exe"); ... Read More
![Debomita Bhattacharjee](https://www.tutorialspoint.com/assets/profiles/210947/profile/60_171666-1594382095.jpg)
3K+ Views
We can handle alerts in Selenium webdriver by using the Alert interface. An alert can be of three types – a prompt which allows the user to input text, a normal alert and a confirmation alert.By default, the webdriver can only access the main page, once an alert comes up, the method switchTo().alert() is used to shift the focus webdriver control to the alert.A normal alert is shown below −A confirmation alert is shown below −A prompt alert is shown below −To accept an alert (to click on the OK button in alert), the method switchTo().alert().accept() is used. To dismiss ... Read More
![Debomita Bhattacharjee](https://www.tutorialspoint.com/assets/profiles/210947/profile/60_171666-1594382095.jpg)
8K+ Views
We can stop a page loading with Selenium webdriver in Chrome browser by using the JavaScript Executor. Selenium can execute JavaScript commands with the help of the executeScript command.To stop a page loading, the command window.stop() is passed as a parameter to the executeScript method. Also, for the Chrome browser we have to configure the pageLoadStrategy to none value and wait for the web element to be available.Finally, we have to invoke window.stop.Syntaxdriver.execute_script("window.stop();")ExampleCode Implementation with JavaScript Executorfrom selenium import webdriver from selenium.webdriver.common.desired_capabilities import DesiredCapabilities from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.by import By #configure pageLoadStrategy ... Read More
![Debomita Bhattacharjee](https://www.tutorialspoint.com/assets/profiles/210947/profile/60_171666-1594382095.jpg)
17K+ Views
We can refresh a webpage using Selenium webdriver in Python. This can be done with the help of the refresh method. First of all, we have to launch the application with the get method.Once a web page is loaded completely, we can then refresh the page with the help of the refresh method. This way the existing page gets refreshed. The refresh method is to be applied on the webdriver object.Syntaxdriver.get("https://www.tutorialspoint.com/tutor_connect/index.php") driver.refresh()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.google.com/") #identify text box m = driver.find_element_by_class_name("gLFyf") #send input m.send_keys("Java") #refresh page driver.refresh()OutputRead More
![Debomita Bhattacharjee](https://www.tutorialspoint.com/assets/profiles/210947/profile/60_171666-1594382095.jpg)
2K+ Views
We can get the HTTP response code in Selenium webdriver with Java. Some of the response codes are – 2xx, 3xx, 4xx and 5xx. The 2xx response code signifies the proper condition, 3xx represents redirection, 4xx shows resources cannot be identified and 5xx signifies server problems.To obtain the response code we shall use the HttpURLConnection class. To have a link to the URL, the method openConnection is used. Also, we have to use the setRequestMethod where the vale Head is to be passed as a parameter.We have to create an instance of the HttpURLConnection class and then apply the connect ... Read More
![Debomita Bhattacharjee](https://www.tutorialspoint.com/assets/profiles/210947/profile/60_171666-1594382095.jpg)
4K+ Views
There are some differences between the xpath and css selector. The format of xpath is //tagname[@attribute='value'] while the format of css selector is tagname[attribute='value'].We can traverse both forward and backward in DOM, i.e we can move from parent to child element and also from child to the parent element with xpath. However for css, we can only traverse from parent to child and not vice-versa.In terms of performance, css is better and faster, while xpath is on a slower side. An xpath can be of two types – absolute which starts from the root node and relative does not require ... Read More
![Debomita Bhattacharjee](https://www.tutorialspoint.com/assets/profiles/210947/profile/60_171666-1594382095.jpg)
7K+ Views
We can select an option from the dropdown with its value attribute in Selenium webdriver by using the Select class. . A dropdown is represented by tag and the options are represented by tag.To select an option with its value we have to use the selectByValue method and pass the value attribute of the option that we want to select as a parameter to that method.SyntaxWebElement v = driver.findElement(By.name("selt")); Select s = new Select(v); s.selectByValue("val1");Let us see the html code of a dropdown having value attribute for its options.Exampleimport org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; import java.util.concurrent.TimeUnit; ... Read More
![Debomita Bhattacharjee](https://www.tutorialspoint.com/assets/profiles/210947/profile/60_171666-1594382095.jpg)
4K+ Views
We can extract text from a webpage using Selenium webdriver and save it as a text file using the getText method. It can extract the text for an element which is displayed (and not hidden by CSS).We have to locate the element on the page using any of the locators like id, class, name, xpath, css, tag name, link text or partial link text. Once the text is obtained, we shall write its content to a file with the help of File class.Let us obtain the text – You are browsing the best resource for Online Education from the below ... Read More
![Debomita Bhattacharjee](https://www.tutorialspoint.com/assets/profiles/210947/profile/60_171666-1594382095.jpg)
3K+ Views
Yes it is possible to manually set the attribute value of a web element in Selenium webdriver using the JavaScript Executor. Selenium can run JavaScript commands with the help of the executeScript method.First, we shall identify the element on which we want to manually set the attribute value with the JavaScript command document.getElementsByClassname. Next to set the attribute we have to use the setAttribute method.Let us modify the background color of the button CHECK IT NOW to yellow. By default it is green on the page.The can be done by setting the style attribute of the background-color to yellow.SyntaxJavascriptExecutor j ... Read More
![Debomita Bhattacharjee](https://www.tutorialspoint.com/assets/profiles/210947/profile/60_171666-1594382095.jpg)
410 Views
We can install TestNG in Eclipse to create a test automation framework with the help of the following steps −First, we have to launch the Eclipse editor, click the menu Help, and then choose Eclipse Marketplace.The Eclipse Marketplace pop-up shall come up, enter TestNG in the search box and click on Go. Once the search result – TestNG for Eclipse gets populated at the top, click on Install.After some time, the confirm Selected Features window comes up, check the TestNG for Eclipse and proceed.Choose the radio button - Keep my installation the same, then click on Confirm.Next, we have to ... Read More