Posts

JAVA Script Executor Code to get the Value (same as getText() method)

Get the element value using Javascript Executor in Selenium WebDriver To get the text of an element we can also use the Javascript Executor. Below is the code to get the text and store in a String variable. 1 2 3 4 5 6 7 @FindBy(id = Checkbox. financialAssistanceAccountEmailId ) public WebElement financialAssistanceAccountEmail; //To get value JavascriptExecutor executor = (JavascriptExecutor) driver; String visit = (String) executor. executeScript ( "return arguments[0].value" , financialAssistanceAccountEmail);

JAVA Script Executor Code to Click on an Element

Click on an Element in Selenium WebDriver Sometimes click() method does not work because two views are loaded at the same time on a page. In this case, we can use the JavascriptExecutor to get the work done. Below is code to click on an element using Javascript Executor. 1 2 3 4 5 6 7 @FindBy(id = Checkbox. financialAssistanceAccountEmailId ) public WebElement financialAssistanceAccountEmail; //Click to element JavascriptExecutor executor = (JavascriptExecutor) driver; executor. executeScript ( "arguments[0].click()" , financialAssistanceAccountEmail);

JAVA Script Executor Code to Scroll to an Element

Scroll to an Element in Selenium WebDriver Some times there is need to scroll to an element and perform some operations. We can use the JavascriptExecutor to scroll down to an element. Below code is used to scroll down to an element. We have used the getLocation().y to get the y axis position of the element. In the same way we can use the x axis position of the element. 1 2 3 4 5 6 7 @FindBy(id = Checkbox. financialAssistanceAccountEmailId ) public WebElement financialAssistanceAccountEmail; //Scroll to element JavascriptExecutor js = (JavascriptExecutor) driver; js. executeScript ( "window.scrollTo(0," +financialAssistanceAccountEmail. getLocation (). y + ")" );

SQL Day 18: Stored Procedure in SQL Server

Image
LO1: What is a Stored Procedure and creating a simple SP LO2: Altering a Stored Procedure LO3: Getting the text of Stored Procedure LO4: Dropping the Stored Procedure LO5: Encrypting the text of Stored Procedure A stored procedure is a group of T-SQL (Transact-SQL) statements. Let’s say we have a situation where we need to execute a query or queries, again and again, we can save that specific query in a stored procedure and call it just by its name. Now we need the employee name and email from tblEmployee table so now we will wrap this query in an SP and execute the SP when required to get the result. Creating a Simple Stored Procedure We can use the Create Procedure command, the syntax is as followed. Syntax: CREATE PROCEDURE AS BEGIN ------Query------- END Example: CREATE PROCEDURE spGetEmployeeName AS BEGIN select name, email from tblEmployee END Once the above command gets executed the SP will be created in the database and will d...

SQL Day 17: Union and Union All

Image
LO1: Purpose of Union and Union All LO2: Difference between Union and Union All LO3: Difference between Joins and Union Prerequisite: Joins Union and Union All is used to combine the result set of two or more queries. To combine two results set, the column list in the select columns, data types, and order of the columns need to be same. Let’s say we have the two table tblcustomer1 and tblcustomer2 with the identical columns in each table. To combine these two result set into one we can use the Union All . select * from tblcustomer1 Union All select * from tblcustomer2 In the above screen, all the rows combined into one result set. Now let’s try to use the Union only and observe the result set. select * from tblcustomer1 Union select * from tblcustomer2 In the above screen, the duplicate row is included only once and the result also gets sorted. Note: In the case of Union, Duplicate rows only get removed from the re...

SQL Day 16: COALESCE() Function

Image
LO1: COALESCE() function with example Prerequisite: Replacing NULL in SQL COALESCE function return the first NON NULL value. Let’s say we have a table called tblPersons which contains data as below. In this table, some persons have the first name, some have the middle name, some have the last name or some have the all the three values. So the COALESCE function will fetch the first NON NULL values from the table i.e. this function will look into the each column value if it finds NULL then it will move to the next column to get the value. This process will continue until all the columns in the select list are traversed. select Id, COALESCE(FirstName, MiddleName, LastName) as Name from tblPersons If all the columns contain the NULL value then that row will be included in the result. That’s all for today. Thank You.