I have one class as below:
public class Module3 {
public static void main(String[] args) throws InterruptedException {
WebDriver driver = new FirefoxDriver();
driver.manage().window().maximize();
findElement1 a = new findElement1();
driver.get("webAddress");
driver.findElement(By.xpath("//*[@id='Username']")).sendKeys("A1");
driver.findElement(By.xpath("//*[@id='Password']")).sendKeys("1");
driver.findElement(By.xpath("//*[@id='loginBox']/form/p/button")).click();
Thread.sleep(2000L);
driver.findElement(By.xpath("//*[@id='mainNav']/li[2]/a")).click();
Thread.sleep(2000L);
driver.findElement(By.xpath("//*[@id='addNewEntryButton']")).click();
WebElement dropdown = driver.findElement(By.xpath("//*[@id='timeEntryTable']/tbody/tr[1]/td[1]/select"));
List<WebElement> dropOptions = dropdown.findElements(By.tagName("Option"));
for (int i=0; i<dropOptions.size(); i++)
{
System.out.println(dropOptions.get(i).getText());
}
Thread.sleep(2000L);
driver.findElement(By.xpath("//*[@id='timeEntryTable']/tbody/tr[1]/td[1]/select")).sendKeys(Keys.ARROW_DOWN);
driver.findElement(By.xpath("//*[@id='timeEntryTable']/tbody/tr[1]/td[5]/input")).sendKeys("5");
driver.findElement(By.xpath("//*[@id='timeEntryTable']/tbody/tr[1]/td[6]/input")).sendKeys("5");
driver.findElement(By.xpath("//*[@id='saveEntryButton']")).click();
Thread.sleep(5000L);
driver.findElement(By.xpath("html/body/div[2]/div[2]/div[2]/div/div[3]/div/header/div/button[4]")).click();
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
a.findValue();
driver.findElement(By.xpath("//button[contains(.,'submit')]")).click();
}
}
Class2:
public class FindElement1 { static WebDriver driver = new FirefoxDriver();
public void findValue() {
driver.get("webaddress");
By by = By.xpath("//button[contains(.,'submit')]");
isElementPresent(by);
driver.findElement(By.xpath(""));
}
public boolean isElementPresent(By by){
try{
driver.findElements(by);
System.out.println("execute");
return true;
}
catch(NoSuchElementException e){
return false;
}
}
}
I want to execute class2's operation into class1 with class1's value in the mentioned place of a.findValue();Is it possible to pass the driver value of class1 into class2