Posts

Showing posts from March, 2025

Write a program to print Reverse words from string

  Public static void main ( String args [] ) { String s="Selenium with java"; Char words[]=s.split(" "); StringBuffer reverse=new Stringbuffer (); For(String word:words) { StringBuffer sb=new StringBuffer(word); Sb.append(sb.reverse().append(" ")); } System.out.println(sb.toString()); }

Write a program to print Reverse String

# Write a program to print  reverse String   Public station void main(String args[]) { String s="patil"; String rev=""; For(int i=s length-1;i>=0;i++) { rev=rev+s.charAt(i); } System.out.println(rev); } Output: litap

Write a program to print all link present on google page || selenium code

# Write a program to get all links present on google page public static void main(String args[])  {         // Set the system property for the ChromeDriver       System.setProperty("webdriver.chrome.driver","c://desktop//cromedriver.exe");        // create new instance of ChromeDriver      WebDriver driver=new ChromeDriver();      //launch browser --> open google home page    driver.get("https://www.google.com");        // find all links on home page     List<WebElement> links=driver.findElements(By.tagName("//a"));           // Iterate through each link and print the href attribute         for(WebElement link:links)         {           String href=link.getAttribute("href").getText();           System.out.println(href);   ...