How To Write Code in Selenium To Click This , Down I Have Attached My Selenium Code.

package Login;

import java.io.File;
import java.io.IOException;

import org.apache.poi.EncryptedDocumentException;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.AfterMethod;

public class Signup {
    WebDriver driver;
     @BeforeMethod
      public void beforeMethod() 
      {
          System.setProperty("webdriver.chrome.driver", "F:\New folder\chromedriver.exe");
           driver = new ChromeDriver();
           driver.get("http://183.82.32.95:8075/index");
      }
  @Test
  public void f() 
  {
      driver.findElement(By.xpath("//a[@class='login-option'][contains(text(),'Login')]")).click();

      driver.findElement(By.xpath("//button[@id='callsignup']")).click();
  }

  @AfterMethod
  public void afterMethod() throws EncryptedDocumentException, InvalidFormatException, IOException 
  {
      String un = Signup.Getdata(1, 0);

      driver.findElement(By.id("Name-new")).sendKeys(un);

      String em= Signup.Getdata(1, 1);

      driver.findElement(By.id("emailids")).sendKeys(em);

      String ps = Signup.Getdata(1, 2);

      driver.findElement(By.id("pswids")).sendKeys(ps);

      String pho = Signup.Getdata(1, 3);

      driver.findElement(By.id("phoneNo")).sendKeys(pho);

      String age = Signup.Getdata(1, 4);

      driver.findElement(By.id("age-new")).sendKeys(age);

      String city = Signup.Getdata(1, 5);

      driver.findElement(By.id("city-new")).sendKeys(city);

      driver.findElement(By.xpath("//input[@id='menrd']")).click();
     try
     {
     WebElement e1 = driver.findElement(By.xpath("/html[1]/body[1]/div[2]/div[3]/div[1]/ss-auth-form[1]/md-card[1]/ss-signup-form[1]/div[1]/form[1]/div[6]"));
     Actions a1 = new Actions(driver);
     a1.moveToElement(e1).click(e1).build().perform();
     }
     catch(Exception e)
     {
         System.out.println("The Button can't Be Clicked!!");
     }
     // driver.findElement(By.xpath("//ss-submit-button[@label='Sign Up']//input[@class='submit']")).click();

  }

  public static String Getdata(int r, int c) throws EncryptedDocumentException, InvalidFormatException, IOException
  {
      File targetfile = new File("F:\Test","Book2.xlsx");  

      Workbook wb = WorkbookFactory.create(targetfile);

        String s1 = wb.getSheet("Test1").getRow(r).getCell(c).getStringCellValue();


        return s1;

  }
}

Image Reference



Source link https://sqa.stackexchange.com/questions/34298/how-to---picture

LEAVE A REPLY

Please enter your comment!
Please enter your name here