Selenium Cheat Sheet Java



Cheat sheet for UNIX Commands and Content. UNIX commands can often be differentiated or grouped into different categories of powerful commands such as File Commands, Process Management commands, Compression, Network related, File Permissions, Searching and SSH related. XPath Expressions Cheat-sheet. CSS Selectors Cheat-sheet. Core Java for Selenium in detail. WebDriver Commands in detail. Selenium and different browsers. Handling Alerts. Handling Windows. Waiting Mechanism. Handling Frames. Handling Lightbox. Taking Screenshots. Auto Suggestive Drop-downs. Handling Tables. Selenium with Java Live Training Selenium is the most sought after testing tool for web based programs and it is compatible with many program languages. However, it is more easy to work on Selenium with Java as the Selenium web driver is written in Java. ITeLearn offers a free orientation for the freshers on selenium live training along with a course in Java. Introduction to Sorting in Java. Sorting in Java is basically arranging a group of elements stored somewhere in a particular order; this order can be both ascending or descending; there come many scenarios in real-time programming where there becomes a necessity to sort the elements as it also makes searching for a particular element easy as the elements can be retrieved easily by an index of. Most Complete Selenium WebDriver Java Cheat Sheet / By Anton Angelov. Most Complete Selenium WebDriver Kotlin Cheat Sheet.


For Python version the link is here


Install Java

To install Java go to this link

Cheat


IDE

You can use any text editor. I recommend Eclipse as it is free and have extensive support. For list of popular editors , this are the links


Download Selenium

Download selenium webdriver in this link


Dirty our hands !


Import Selenium



Browsers support (Firefox , Chrome , Internet Explorer, Edge , Opera)

Driver setup:

Chrome:

System.se­tPr­ope­rty­('we­bdr­ive­r.chrome.d­riv­er', “'Pat­h To­ chromedr­ive­r');

To download: Visit Here


Firefox:

System.se­tPr­ope­rty­('we­bdr­ive­r.g­eck­o.d­riv­er', '­Pat­h To­ g­eck­odr­ive­r');

To download: Visit GitHub


Internet Explorer:

System.se­tPr­ope­rty­('we­bdr­ive­r.ie.d­riv­er', 'Pat­h To­ IEDriverServer.exe');

To download: Visit Here

Edge:

System.se­tPr­ope­rty­('we­bdr­ive­r.edge.d­riv­er', 'Pat­h To­ MicrosoftWebDriver.exe');

To download: Visit Here


Opera:

System.se­tPr­ope­rty­('we­bdr­ive­r.opera.d­riv­er', 'Pat­h To­ operadriver');

To download: visit GitHub

Browser Arguments:

–headless

To open browser in headless mode. Works in both Chrome and Firefox browser

–start-maximized

To start browser maximized to screen. Requires only for Chrome browser. Firefox by default starts maximized

–incognito

To open private chrome browser

–disable-notifications

To disable notifications, works Only in Chrome browser

Example:


Alternative


Launch URL


Retrieve Browser Details:


Navigation


Locating Elements

By id

<input id=”login” type=”text” />


By Class Name

<input class=”gLFyf” type=”text” />


By Name

<input name=”z” type=”text” />


By Tag Name

<div id=”login” >…</div>


By Link Text

<a href=”#”>News</a>


By XPath

<form id=”login” action=”submit” method=”get”>

Username: <input type=”text” />

Password: <input type=”password” />

</form>


By CSS Selector

<form id=”login” action=”submit” method=”get”>

Username: <input type=”text” />

Password: <input type=”password” />

</form>


Clicking / Input text

Clicking button


Send Text

Cheat


Waits

Implicit Waits

Vintage magnavox stereo. An implicit wait instructs Selenium WebDriver to poll DOM for a certain amount of time, this time can be specified, when trying to find an element or elements that are not available immediately.

Selenium Cheat Sheet Python


Explicit Waits

Explicit wait make the webdriver wait until certain conditions are fulfilled . Example of a wait


List of explicit waits

  • alertIsPresent()
  • elementSelectionStateToBe()
  • elementToBeClickable()
  • elementToBeSelected()
  • frameToBeAvaliableAndSwitchToIt()
  • invisibilityOfTheElementLocated()
  • invisibilityOfElementWithText()
  • presenceOfAllElementsLocatedBy()
  • presenceOfElementLocated()
  • textToBePresentInElement()
  • textToBePresentInElementLocated()
  • textToBePresentInElementValue()
  • titleIs()
  • titleContains()
  • visibilityOf()
  • visibilityOfAllElements()
  • visibilityOfAllElementsLocatedBy()
  • visibilityOfElementLocated()



Loading a list of elements like li and selecting one of the element



Read Attribute


Get CSS

CSS values varies on different browser, you may not get same values for all the browser.


Capture Screenshot

This will saved the file as in the path of destFile.


isSelected()

isSelected() method in selenium verifies if an element (such as checkbox) is selected or not. isSelected() method returns a boolean.


isDisplayed()

isDisplayed() method in selenium webdriver verifies and returns a boolean based on the state of the element (such as button) whether it is displayed or not.


isEnabled()

is_enabled() method in selenium python verifies and returns a boolean based on the state of the element (such as button) whether it is enabled or not.

Minimum modules to import


Created : 17 December 2019

MySQL cheat sheet provides a single page that contains all of the most commonly used commands and statements. This one-page cheat sheet helps us to work with MySQL database more effectively and quickly.

MySQL is an open-source widely used RDBMS database that provides high performance and scalable web-based and embedded database applications for the customers. It has many useful commands and statements to work with web-based and embedded database applications. The command in MySQL is a powerful directive used to perform a specific task or service. They are very helpful for every developer to know and use these queries for interacting with the MySQL databases in real-time. MySQL commands are based on a structured query language (SQL) which can support various operating systems such as Linux, UNIX, macOS, and Windows.

We can see a list of all commands in MySQL using the below query:

Let us see the most commonly used commands and statements that we need to create and manage the database in MySQL.

MySQL command-line client commands

This command allows us to connect with MySQL Server with a username and passwords using below syntax.

If you want to connect with a particular database, use this syntax:

If you want to set a new password, use this syntax:

We can use the 'exit' command to quit the MySQL command-line client.

We can clear the console window in Linux using the below command:

It is to be noted that there is no command available for Windows to clear the console window of MySQL.

Working with Database

A database stores the organized collection of records that can be accessed and manage by the user very easily. It holds the data into tables, rows, columns, and indexes that help us to find the relevant information quickly. We can create a database using the below syntax. It also checks the database name, whether it already exists or not.

If you want to change the current database with another database on which you are working, use the below syntax:

We can delete a particular database along with its associated files permanently using the below syntax:

To show all databases in the current server, use this syntax:

Working with tables

A table is a collection of related data stored in a row and column format within a database. We can create a new table using the below syntax. It also checks the table name, whether it already exists or not.

We can use the INSERT statement to add a record into the table, which is given below:

We can delete a particular table along permanently using the below syntax:

To show all tables in the current database, use this syntax:

We can add a new column to the table or can drop any column, use the following statements:

We can add a primary key into the table, or can remove it from the table, use the following statements:

If you want to add an index with a specific name on a column, use this syntax:

We can show the structure of a table using the below statement:

We can show the column information of a table using the below statement:

Working with Indexes

An index is a data structure that allows us to the faster retrieval of records on a database table. If we want to add an index in the table, we will use the statement as follows:

To drop an index, use this statement:

Working with View

The View in MySQL is used to create a virtual table by joining one or more tables. We can create or replace a VIEW by using SELECT statements as follows:

We can remove a view using the below statement:

We can rename a view using the below statement:

If you want to show all the views available in the database, use the below statement:

Working with Stored Procedure

A stored procedure is a group of SQL statements with a specific name that accepts some inputs and performs a certain task. It saves time to write the same code again and again in a database. We can create a stored procedure in MySQL using the below statements:

If you want to remove an existing stored procedure from the database, use the below statement:

If you want to show all procedures available in the database, use the below statement:

Working with Triggers

A trigger is a procedural code in a database that automatically executed whenever certain events on a particular table or view in the database occur. We can create a new trigger using the below statements:

If you want to remove an existing trigger, use the below statement:

If you want to show all triggers available in the database, use the below statement:

Working with Stored Functions

A stored function in MySQL is a set of SQL statements that perform some task/operation and return a single value. It is one of the types of stored programs in MySQL. When you will create a stored function, make sure that you have a CREATE ROUTINE database privilege. The syntax of creating a stored function in MySQL is given below:

If you want to remove an existing trigger, use the below statement:

If you want to show all triggers available in the database, use the below statement:

Popular queries based on tables

Here, we will see some of the essential queries executed on tables to find the relevant information.

If we want to show all the table data, use this syntax:

If we want to show the data of some selected columns from a table, use this syntax:

We can get filtered result from the table using the below statement:

Sometimes our tables contain duplicates rows. But we want to show only the unique(distinct) rows, in that case, the below statements will be executed:

Sometimes, the column name of a table is not appropriate for the output. In that case, we can use the below statement to change the column name in the result:

If we want to get the output from more than one table, we need to use the JOIN operation. The syntax for joining two tables is given below:

We can count the number of rows with this statement:

We can sort the result set using the following statement:

If we want to group rows into the result set, use the below syntax:

If we want to update the rows of the table, use the below syntax:

We can delete all records from the table using the below syntax:

Searching data from the table

We can search for data using the LIKE clause, as shown below:

We can also search for text using a regular expression with RLIKE operator, as shown below:

Control Option to the Administrator

Here, we will see the features that provide control options to the administrators and users on the database.

The grant statement enables system administrators to assign privileges and roles to the MySQL user accounts for accessing the database.

The revoke statement enables system administrators to revoke privileges and roles to the user accounts on the database in the past.

Selenium Cheat Sheet Java Programming

Selenium Cheat Sheet Java