Posts

Showing posts from April, 2024

Window POPUP's/Tabs/New window

Window Handler - click on element opening new page/Tab public class WindowHandlersmultplecircle { static By linkedin = By. xpath ( "//a[contains(@href,'linkedin')]" ); static By facebook = By. xpath ( "//a[contains(@href,'facebook')]" ); static By twitter = By. xpath ( "//a[contains(@href,'twitter')]" ); static By youtube = By. xpath ( "//a[contains(@href,'youtube')]" ); @Test public void windowhandleCircle() throws InterruptedException { WebDriver driver = new ChromeDriver(); driver .get( "https://opensource-demo.orangehrmlive.com/web/index.php/auth/login" ); driver .manage().window().maximize(); //System.out.println(driver.getCurrentUrl()); Thread. sleep (4000); String parentWindowID = driver .getWindowHandle(); driver .findElement( twitter ).click(); //System.out.println(driver.getCurrentUrl()); driver .findElement( facebook ).click(); //System.out.println(driver.getCurrentU...

FrameHandling

  IFrame Handle/ Frame: Frame is a Web element  Browser--->page: webelements--->frame: webelements When we are writing  WebDriver driver = new ChromerDriver(); driver.get("");//here driver is pointing to page. if we want to switch to frame we need to switch to the frame driver .switchTo().frame(ID/NAME); driver .switchTo().frame( "mainpanel" ); Thread. sleep (4000); driver .findElement(By. linkText ( "CONTACTS" )).click(); driver .switchTo().defaultContent();

JS -Alerts ,Popup's, File Upload & Basic authentication in URL

 package AlersJS; import org.openqa.selenium.Alert; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.interactions.Actions; import org.testng.annotations.Test; public class AlersJavaScript { @Test public void AlertsExample() throws InterruptedException { driver .get( "https://cgi-lib.berkeley.edu/ex/fup.html" ); driver .findElement(By. name ( "upfile" )).sendKeys( "C:\\Users\\windo\\Desktop\\Resume\\fileupload.txt" ); /* * Alerts are 3 types 1- alerts-OK 2-confirmation-OK & Cancel 3-popup box- Text * box , Ok and Cancel */ WebDriver driver = new ChromeDriver(); driver.get("https://testpages.eviltester.com/styled/alerts/alert-test.html"); driver.findElement(By.id("alertexamples")).click(); // 1- Alert Box with OK botton and Text   Alert alt = driver.switchTo().alert();    Thread.sleep(500); String a...

Window Size - Max,Min, Webelement Size

  Window Size : driver.manage().window().maximize(); Thread.sleep(5000); driver.manage().window(). fullscreen (); Thread.sleep(5000); driver.manage().window().minimize(); Thread.sleep(5000); driver.manage().window().maximize(); Get the field Size , height and widht of the element Dimension dim = new Dimension (414,700); driver .manage().window().setSize( dim ); //#APjFqb driver .get( "https://www.google.com/" ); WebElement searchbutton = driver .findElement(By. cssSelector ( "#APjFqb" )); System. out .println( searchbutton .getSize()); System. out .println( searchbutton .getSize().getHeight()); System. out .println( searchbutton .getSize(). getWidth ()); System. out .println( searchbutton .getLocation()); Get Element Colour and font size : //BackGroup colours : driver .get( "https://naveenautomationlabs.com/opencart/index.php?route=account/register" ); WebElement Submit = driver .findElement(By. xpath ( "//input[@value='Contin...

Scrolling and SendKeys with Pause/Keys.TAB- Actions

* Scroll to element and click on element */ WebElement buttom = driver .findElement(By. cssSelector ( "#trigger-pro" )); //act.sendKeys(Keys.CONTROL).sendKeys(Keys.END); act .scrollToElement( buttom ).click( buttom ).build().perform(); } Scroll to bottom/top of page : act .sendKeys(Keys. CONTROL ).sendKeys(Keys. END ).perform(); act .sendKeys(Keys. CONTROL ).sendKeys(Keys. HOME ).perform(); SendKeys with Pause : searchText = driver .findElement(By. name ( "search" )); String textData = "sudheerReddy" ; Actions act = new Actions( driver ); char [] aa = textData .toCharArray(); for ( char bb : aa ) { System. out .println( bb ); act .sendKeys( searchText , String. valueOf ( bb )).build().perform(); } SendKeys with TAB/Pause WebElement firstName = driver .findElement(By. name ( "firstname" )); Actions act = new Actions( driver ); act .sendKeys( firstName , ( "Sudheer" )) ...