Searching.java
package Main;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.PageFactory;
public class Searching {
static WebDriver driver=new FirefoxDriver();
static Locators elements = PageFactory.initElements(driver, Locators.class);
public static void main(String[] args) throws InterruptedException {
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.get("https://www.google.com");
driver.manage().window().maximize();
elements.anyname1.sendKeys("test");
elements.anyname2.sendKeys("aasdasdasd");
elements.Seachbtn.click();
Thread.sleep(2000);
elements.rqtbtn.click();
}
}
Locators.java
package Main;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.*;
public class Locators {
@FindBy(how=How.XPATH, using="//input[@name='xyz']")
public static WebElement anyname1;
@FindBy(how=How.XPATH, using="//input[@name='xyz']")
public static WebElement anyname2;
@FindBy(how=How.XPATH, using="//input[@name='xyz']")
public static WebElement Seachbtn;
@FindBy(how=How.XPATH, using="//input[@type='submit' and @value='xyz']")
public static WebElement sendrqtbtn;
}
package Main;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.PageFactory;
public class Searching {
static WebDriver driver=new FirefoxDriver();
static Locators elements = PageFactory.initElements(driver, Locators.class);
public static void main(String[] args) throws InterruptedException {
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.get("https://www.google.com");
driver.manage().window().maximize();
elements.anyname1.sendKeys("test");
elements.anyname2.sendKeys("aasdasdasd");
elements.Seachbtn.click();
Thread.sleep(2000);
elements.rqtbtn.click();
}
}
Locators.java
package Main;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.*;
public class Locators {
@FindBy(how=How.XPATH, using="//input[@name='xyz']")
public static WebElement anyname1;
@FindBy(how=How.XPATH, using="//input[@name='xyz']")
public static WebElement anyname2;
@FindBy(how=How.XPATH, using="//input[@name='xyz']")
public static WebElement Seachbtn;
@FindBy(how=How.XPATH, using="//input[@type='submit' and @value='xyz']")
public static WebElement sendrqtbtn;
}
No comments:
Post a Comment