Thursday, March 31, 2022

Selenium TestNG PART - 1

 TestNG :

  •      TestNG is an open-source testing framework where NG stands for 'Next Generation.
  •      Failed test cases can be run separately using TestNG.
  •      Test Reports can be generated using TestNG.

Program :

 package selenium;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.chrome.ChromeDriver;

import org.testng.Assert;

import org.testng.annotations.Test;


public class NewTestNG {

public String baseUrl = "https://suriyaparithy.blogspot.com/";

String driverPath = "C:\\Selenium\\chromedriver\\chromedriver.exe";

public WebDriver driver ;

  @Test

  public void homepage() {

  System.out.println("launching chrome browser");

  System.setProperty("webdriver.chrome.driver","C:\\Selenium\\chromedriver\\chromedriver.exe");

  WebDriver driver = new ChromeDriver();

  driver.manage().window().maximize();

  driver.get(baseUrl);

  String expectedTitle = "Learning Oracle Application and Software Testing";

  String actualTitle = driver.getTitle();

  Assert.assertEquals(actualTitle, expectedTitle);

  }

}


Selenium WebDriver - Google Search Page

 package selenium;


import java.time.Duration;

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.WebElement;

import org.openqa.selenium.chrome.ChromeDriver;


public class Googlesearchpage {


public static void main(String[] args) throws InterruptedException {

System.setProperty("webdriver.chrome.driver","C:\\Selenium\\chromedriver\\chromedriver.exe");

WebDriver driver = new ChromeDriver();

driver.manage().window().maximize();

driver.get("https://google.com");

System.out.println(driver.getCurrentUrl());

               System.out.println(driver.getTitle());

        

               driver.manage().timeouts().implicitlyWait(Duration.ofMillis(5000));

                Thread.sleep(5 * 1000);

        

             WebElement searchBox = driver.findElement(By.name("q"));

             WebElement searchButton = driver.findElement(By.name("btnK"));

        

        searchBox.sendKeys("suriyaparithy");

        searchButton.click();

        

        System.out.println(driver.getTitle());

        System.out.println(driver.getCurrentUrl());

        

        System.out.println(searchBox.getAttribute("value"));

        

        searchButton.getText();

        searchBox = driver.findElement(By.name("q"));

        searchBox.getAttribute("value");

}


}

Java Program Conditional Statement PART - 4

 package selenium;

public class Conditionalstatement {

public static void main(String[] args) {

int number =6;

//using ternary

System.out.println(number%2==0 ? "Even Number" : "Odd Number");

int person_age =15;

//Using Ternary Operator

System.out.println(person_age>=18 ? "Eligible for vote" : "Not eligible for vote");

//IF ELSEIF CONDITION

int num=10;

if(num>0)

{

System.out.println("Number is positive");

}

else if (num<0) 

{

System.out.println("Number is negative");

}

else if (num==0) 

{

System.out.println("Number is zero");

}

}

}


Java Program Operators PART - 3

 package selenium;

public class Operators {

public static void main(String[] args) {

//Conditional Operator - Use of Ternary operator

int age =20;

String res=(age >=18) ? "Eligible to vote": "Not eligible to vote";

System.out.println(res);

int a = 10;

int res1=++a; //pre increment   11 //first increases value of a then assignment happens

System.out.println(res1); //10

System.out.println(a);

boolean x=true;

boolean y=false;

System.out.println(x && y); // false if both values are true will return true if not false.&& - AND operator

System.out.println(x || y); // true if either one is true give true.|| - OR operator

System.out.println(!x); //false

System.out.println(!y); //true

}

}


Java Program For Data Types Part-2

 package selenium;

public class Datatypes {

public static void main(String[] args) {

//single line variable declaration

int a=10, b=20, c=30;

System.out.println(a);

        System.out.println(b);

System.out.println(c);

System.out.println(a+b); // add the a,b value

  long c1=123456789L; //Long data type

        System.out.println(c1);

    

                 int person_age=30; // Number data type

        System.out.println(person_age);

 float item_price=15.5f; //have to specify with f character if it is a float

 System.out.println(item_price);

char grade='B'; // Char data type

System.out.println(grade);

boolean status1=true;

boolean status2=false;

System.out.println(status1+" "+status2);

String person_name="Suriya Parithy"; // Name data type

System.out.println(person_name);

}

}

Java Programming Part - 1

 package selenium;
public class Firstprogram {
public static void main(String[] args) {
System.out.println("This is my first java program written by suriya"); // print statement in console
System.out.println("10+20"); //prints the string
System.out.println(10+20); //evaluates the operation
System.out.println("Welcome to Selenium");
}
}

Wednesday, March 30, 2022

Selenium WebDriver Browser Commands PART - 2

 Get Commands

  • Get commands are used to collect various information about the page that we deal with here are some important “get” commands.

1. Get-Command  - get()

  •      get() command is used to open a new browser window and it will find/fetch the page that you have given.

2. Get Title Command - getTitle() 

  • getTitle() is used to get the title of the current page.

3. Get Current URL Command -  getCurrentUrl() 

  • This command is used to get the current URL of the browser.

4. Get Page Source Command –  getPageSource() 

  • This command is used to get the source code of the page.

5. Get Text –  getText() 

  • This command is used to fetch the text of the element.

NAVIGATE COMMANDS

1. Navigate To Command–  navigate().to() 

  • This command is like Get() command.
  • It opens a new browser window and it will find/fetch the page that you have given.

2. Navigate Refresh Command–  navigate().refresh() 

  • This command is used to refresh the current page.

3. Navigate to the back page–  navigate().back() 

  • This command is used to go back by one page in the browser’s history.

4. Navigate to the forward page–  navigate().forward() 

  • Takes you forward by one page on the browser’s history.

5. Refresh page –  navigate().refresh() 

  • It refreshes the current page.

 

OTHER USEFUL COMMANDS


1. switch to command – ” driver.switchTo().window(“windowName”) ”

  • This command is used to switch from one window to another.

2. Switching  from one iframe to another – ” driver.switchTo().frame(“frameName”) ”

  • This command is used to switch from one iframe to another iframe.

3. Handling Alerts – ” driver.switchTo().alert() ”

  • This command is used to handle alerts.

4. Close Command –  close() 

  • This command closes the current window of the browser.

5. Quit Command – quit() 

  • This command is used to quit the browser and all the opened windows in the browser.

Selenium WebDriver Browser Commands PART - 1

 package selenium;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class Browsercommands {
@SuppressWarnings("deprecation")
          public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.chrome.driver","C:\\Selenium\\chromedriver\\chromedriver.exe");
         
//Initialize WebDriver
WebDriver driver = new ChromeDriver();

// Wait For the Page To Load
driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);

// Go to URL
driver.get("https://suriyaparithy.blogspot.com/");

// Maximize Window
driver.manage().window().maximize();

// Storing Title name in String variable so that we can get the title name
String title = driver.getTitle();

// Printing the Title name in 2 ways
// 1st way
System.out.println(title);

// 2nd way
System.out.println("Title is : " + title);

// Storing Title length in Int variable because we are dealing with Integers that's why int is used.
int TitleLength = driver.getTitle().length();

// Printing Title length
System.out.println("Length of the Title is : " + TitleLength);

// Storing URL in String variable
String curl = driver.getCurrentUrl();

// Printing URL on Console Window
  System.out.println("URL is : " + curl);

// Storing URL length
int curl2 = driver.getCurrentUrl().length();

// Printing URL length on console Window
  System.out.println("URL length is : " + curl2);

 // COMMAND FOR NAVIGATION THROUGH PAGES.
//Open the TCA Page
   String tca =  driver.findElement(By.linkText("TCA")).getText();        
      
 // Print the Tab name which is being clicked.
   System. out.println("Name of the Tab which is being clicked is: " + tca);

  // Click on the TCA Tab
   driver.findElement(By.linkText("TCA")).click();

  //Navigate to the previous Page.
      driver.navigate().back();
      Thread.sleep(1000);
      String pre = driver.getTitle();

    // Print the text of the previous page
        System.out.println("Text of the previous page is : " + pre);

     //Navigate to the Next page.
         driver.navigate().forward();
     Thread.sleep(1000);

   // Print the text of the NEXT page
         String next = driver.getTitle();
 System.out.println("Text of the NEXT page is : " + next);

    // COMMAND FOR REFRESHING THE CURRENT PAGE
         driver.navigate().refresh();

    // PAGE SOURCE COMMAND
         
  /* Storing Page Source in String variable.
           String source = driver.getPageSource();
           Thread.sleep(1000);

        // Printing the Page Source
           System.out.println("Page source : " + source);

        // Storing Page Source length in Int variable
           int sou = driver.getPageSource().length();

         // Printing the Page Source length
           System.out.println("Length of the page source is : " + sou);*/

         //close the browser or page currently which is having the focus.
           driver.close();

          //Close all the windows.
         driver.quit();
}
}

Tuesday, March 29, 2022

Update Customer Credit Card API in Oracle Apps R12

DECLARE
   x_return_status     VARCHAR2 (1000);
   x_msg_count         NUMBER;
   x_msg_data          VARCHAR2 (4000);
   x_card_id           NUMBER;
   x_msg_data_out      VARCHAR2 (240);
   x_mesg              VARCHAR2 (240);
   x_count             NUMBER;
   x_response          iby_fndcpt_common_pub.result_rec_type;
   l_card_instrument   iby_fndcpt_setup_pub.creditcard_rec_type;
   v_context           VARCHAR2 (10);
   p_init_msg_list     varchar2(50);
   p_commit            varchar2(50);
   l_msg_index_out          NUMBER;
   l_error_message          VARCHAR2 (100);
BEGIN
     l_card_instrument.card_id          :='&card_id';                           
     l_card_instrument.expiration_date :=to_date('12/23/2018','mm/dd/yyyy');   
                   
     
     IBY_FNDCPT_SETUP_PUB.UPDATE_CARD
                       (p_api_version          => 1.0,
                        x_return_status        => x_return_status,
                        x_msg_count            => x_msg_count,
                        x_msg_data             => x_msg_data,
                        p_card_instrument      => l_card_instrument,
                        x_response             => x_response,
                        p_init_msg_list        => fnd_api.g_false,
                        p_commit               => fnd_api.g_true
                        );
        DBMS_OUTPUT.put_line ('output information');
        DBMS_OUTPUT.put_line ('x_msg_count = ' || x_msg_count);
        DBMS_OUTPUT.put_line ('x_return_status = ' || x_return_status);
     IF x_msg_count > 0 THEN
         FOR i IN 1 .. x_msg_count
         LOOP
            apps.fnd_msg_pub.get (p_msg_index          => i,
                                  p_encoded            => fnd_api.g_false,
                                  p_data               => x_msg_data,
                                  p_msg_index_out      => l_msg_index_out
                                 );
         END LOOP;

         IF l_error_message IS NULL
         THEN
            l_error_message := SUBSTR (x_msg_data, 1, 250);
         ELSE
            l_error_message :=
                       l_error_message || ' /' || SUBSTR (x_msg_data, 1, 250);
         END IF;

         DBMS_OUTPUT.put_line ('*****************************************');
         DBMS_OUTPUT.put_line ('API Error : ' || l_error_message);
         DBMS_OUTPUT.put_line ('*****************************************');
      END IF;
END;