- Trending Categories
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 2617 Articles for Java
![Debomita Bhattacharjee](https://www.tutorialspoint.com/assets/profiles/210947/profile/60_171666-1594382095.jpg)
13K+ Views
We can switch tabs using Selenium. First we have to open a link in a new tab. The Keys.chord method along with sendKeys is to be used. The Keys.chord method allows you to pass more than one key at once. The group of keys or strings are passed as arguments to the method.We shall pass Keys.CONTROL and Keys.ENTER as arguments to the Keys.chord method. The whole string is then passed as an argument to the sendKeys method. Finally, the sendKeys method has to be applied on the link which is identified by driver.findElement method.SyntaxString clickl = Keys.chord(Keys.CONTROL, Keys.ENTER); driver.findElement(By.xpath("//*[text()='Terms of ... Read More
![Debomita Bhattacharjee](https://www.tutorialspoint.com/assets/profiles/210947/profile/60_171666-1594382095.jpg)
931 Views
We can capture browser logs with Selenium. We have to type cast the RemoteWebDriver to driver and then initialize it. Next, we have to use the setLogLevel method. The import org.openqa.selenium.remote.RemoteWebDriver statement needs to be added in code for the RemoteWebDriver.Syntax((RemoteWebDriver) driver).setLogLevel(Level.INFO);Exampleimport org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.remote.RemoteWebDriver import java.util.logging.Level; public class BrwLogs{ public static void main(String[] args) { System.setProperty("webdriver.chrome.driver", "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe"); WebDriver driver = new ChromeDriver(); // Enable logging with setLogLevel method ((RemoteWebDriver) driver).setLogLevel(Level.INFO); driver.get("https://www.tutorialspoint.com/index.htm"); ... Read More
![Debomita Bhattacharjee](https://www.tutorialspoint.com/assets/profiles/210947/profile/60_171666-1594382095.jpg)
3K+ Views
We can handle authentication popup with Selenium. To do this, we have to pass the user credentials within the URL. We shall have to add the username and password to the URL.Syntaxhttps://username:password@URL https://admin:admin@the−nternet.herokuapp.com/basic_auth Here, the admin is the username and password. URL − www.the-internet.herokuapp.com/basic_authLet us work and accept the below authentication popup.Exampleimport org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; public class AuthnPopup{ public static void main(String[] args) { System.setProperty("webdriver.chrome.driver", "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe"); WebDriver driver = new ChromeDriver(); String u = "admin"; // adding username, password with ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
520 Views
Following is the correct syntax to use LIKE with search variable −String sqlQuery; sqlQuery = "select *from yourTableName where yourColumnName like '%" +yourSearchVariableName + "%'";Let us create a table −mysql> create table demo19 −> ( −> id int not null auto_increment primary key, −> name varchar(50) −> ); Query OK, 0 rows affected (3.48 sec)Insert some records into the table with the help of insert command −mysql> insert into demo19(name) values('John Smith'); Query OK, 1 row affected (0.15 sec) mysql> insert into demo19(name) values('David Miller'); Query OK, 1 row affected (0.15 sec) mysql> insert into demo19(name) values('Adam Smith'); ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
2K+ Views
Yes, for this, use the concept of ArrayList in Java. The syntax is as follows −ArrayList anyVariableName= new ArrayList();Let us create a table −mysql> create table demo10 −> ( −> id int not null auto_increment primary key, −> name varchar(20) −> ); Query OK, 0 rows affected (2.19 sec)Insert some records into the table with the help of insert command −mysql> insert into demo10(name) values('John'); Query OK, 1 row affected (0.23 sec) mysql> insert into demo10(name) values('Bob'); Query OK, 1 row affected (0.12 sec) mysql> insert into demo10(name) values('David'); Query OK, 1 row affected (0.13 sec)Display records from ... Read More
![Raunak Jain](https://www.tutorialspoint.com/assets/profiles/256620/profile/60_114506-1601705566.jpg)
2K+ Views
Java is one of the most popular enterprise languages right now. It is the core of object oriented programming and comes with great platforms to build enterprise level applications and testing platforms. For newbies, installing and getting accommodated with the Java environment might take some time initially.Docker Containers allow you to access Java Runtime Environment inside them, thus providing an easily manageable packaged environment with libraries already installed. If you have Docker installed on your local machine, instead of running Java applications and going through all the hustle, you can easily build a Java image by pulling it directly through ... Read More
![Debomita Bhattacharjee](https://www.tutorialspoint.com/assets/profiles/210947/profile/60_171666-1594382095.jpg)
2K+ Views
We can close a specific window with Selenium webdriver. The getWindowHandles and getWindowHandle methods can be used to handle child windows. The getWindowHandles method is used to store all the opened window handles in the Set data structure.The getWindowHandle method is used to store the window handle of the browser window in focus. We have to add import java.util.Set and import java.util.List statements to accommodate Set data structure in our code.By default, the driver object can only access the elements of the parent window. In order to switch its focus from the parent to the child window, we shall take ... Read More
![Debomita Bhattacharjee](https://www.tutorialspoint.com/assets/profiles/210947/profile/60_171666-1594382095.jpg)
5K+ Views
We can scroll a specific DIV using Selenium webdriver. Selenium cannot handle scrolling directly. It takes the help of the Javascript Executor to do scrolling action to a specific DIV.First of all we have to identify the specific DIV up to which we have to scroll to with the help of xpath or css locator. Next we shall take the help of the Javascript Executor to run the Javascript commands. The method executeScript is used to execute Javascript commands in Selenium. We have to use the scrollIntoView method in Javascript and pass true as an argument to the method.SyntaxWebElement m=driver.findElement(By.xpath("//div[@class='slick-track']")); ... Read More
![Debomita Bhattacharjee](https://www.tutorialspoint.com/assets/profiles/210947/profile/60_171666-1594382095.jpg)
5K+ Views
We can close the child browser window in Selenium webdriver. The getWindowHandles and getWindowHandle methods can be used to handle child windows. The getWindowHandles method is used to store all the opened window handles in the Set data structure.The getWindowHandle method is used to store the browser window currently active. To iterate over the window handles, the iterator method is used. We have to add import java.util.Set to accommodate Set and import java.util.List and import java.util.Iterator statements to accommodate iterator in our code.By default, the driver object can access the elements of the parent window. In order to switch its focus ... Read More
![Himanshu shriv](https://www.tutorialspoint.com/assets/profiles/163160/profile/60_256934-1579586422.jpg)
12K+ Views
String is an immutable class and its object can’t be modified after it is created but definitely reference other objects. They are very useful in multithreading environment because multiple threads can’t change the state of the object so immutable objects are thread safe.String buffer is mutable classes which can be used to do operation on string object such as reverse of string, concating string and etc. We can modify string without creating new object of the string. String buffer is also thread safe.Also, string concat + operator internally uses StringBuffer or StringBuilder class. Below are the differences.Sr. No.KeyStringStringBuffer1BasicString is an ... Read More