Sample Webdriver program to open firefox and login


package MyPackage;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.firefox.*;
public class Logininto {


public static void main(String[] args) {
Logininto firefox = new Logininto();
   firefox.Login_vtiger();
}

public FirefoxDriver Login_vtiger(){
FirefoxDriver Driverobj=new FirefoxDriver();
Driverobj.get("http://localhost:8888");
Driverobj.manage().timeouts().implicitlyWait(40,TimeUnit.SECONDS);
Driverobj.findElementByName("user_name").sendKeys("admin");
Driverobj.findElementByXPath("//div/input[@name='user_password']").sendKeys("admin");
Driverobj.findElementByXPath("//div/input[@id ='submitButton']").click();
return Driverobj;

}
}

------------------------------------------------------------------------------------------------------------


package Vtiger;

import java.util.List;

import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;

import Vtiger.Logininto;
public class Creat_Lead {

/**
* @param args
*/
public static void main(String[] args) {
Creat_Lead CL=new Creat_Lead();
CL.CreateLeadMarketing();

}
public void CreateLeadMarketing() {
FirefoxDriver Driver= new Logininto().Login_vtiger();
Driver.findElementByXPath("//a[@href='index.php?module=Leads&action=index']").click();
Driver.findElementByXPath("//a[@href='index.php?module=Leads&action=EditView&return_action=DetailView&parenttab=Marketing']").click();
WebElement sel = Driver.findElementByXPath("//Select[@class='small' and @name='salutationtype']");
Select Listboxobj=new Select(sel);
Listboxobj.selectByVisibleText("Mr.");
Driver.findElementByXPath("//input[@name='firstname']").sendKeys("Vivek");
Driver.findElementByXPath("//input[@name='lastname']").sendKeys("Kaushik");
Driver.findElementByXPath("//input[@name='company']").sendKeys("AonHewitt");
Driver.findElementByXPath("//input[@type='radio' and @value='T']").click();
Driver.findElementByXPath("//input[@class='crmbutton small save' and @name='button']").click();
// i=Driver.findElements(By.xpath("//table[@class='lvt small']/tbody/tr")).size();




}

}

No comments:

Post a Comment