I am using Selenium webDriver with page object design pattern. I want to automate this scenario. Here is the screenshot, tells about a sharing document. In the username field when I enter a name it will automatically displays in the list and I want to do double click the displayed name. but how ? Here is the screenshot for send document module.
package Pages;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.ui.Select;
public class ShareDocument
{
@FindBy(linkText="App")
WebElement app;
@FindBy(linkText="Documents")
WebElement documents;
@FindBy(xpath="//*[@id='list-container']/ul/li[3]/span[8]/a[2]/i")
WebElement share;
@FindBy(id="browseUsersEmail")
WebElement perm;
@FindBy(xpath="//*[@id='24@user']/span[1]")
WebElement name_dropdown;
@FindBy(id="other_notes")
WebElement msg;
@FindBy(className="btn-primary")
WebElement button;
//constructor
public ShareDocument(WebDriver driver)
{
PageFactory.initElements(driver, this);
}
public void setApp()
{
app.click();
}
public void setDocument()
{
documents.click();
}
public void setShare()
{
share.click();
}
public void setPerm(String per)
{
perm.clear();
perm.sendKeys(per);
}
public void select_List(String Name)
{
Select namedropdown=new Select(name_dropdown);
namedropdown.selectByVisibleText(Name);
}
public void setMesg(String me)
{
msg.clear();
msg.sendKeys(me);
}
public void setButton()
{
button.submit();
}
}
package Test;
import org.testng.annotations.Test;
import Pages.ShareDocument;
import Pages.LoginPage;
import org.testng.Assert;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.BeforeTest;
public class ShareDocTest
{
WebDriver driver;
@BeforeTest
public void setup()
{
System.setProperty("webdriver.firefox.marionette","pathToGeckodriver");
driver=new FirefoxDriver();
driver.manage().window().maximize();
driver.get("http://54.68.159.204/docmgr");
}
@Test(priority=1)
public void verify1()
{
LoginPage login=new LoginPage(driver);
login.set_username("docmanager");
login.set_password("1");
login.click_button();
Assert.assertTrue(driver.getPageSource().contains("Hello Administrator"));
}
@Test(priority=2)
public void verify2()
{
ShareDocument doc=new ShareDocument(driver);
doc.setApp();
doc.setDocument();
doc.setShare();
doc.setPerm("huggins");
doc.select_List("huggins");
doc.setMesg("Selenium notes");
doc.setButton();
Assert.assertTrue(driver.getPageSource().contains("Hello Administrator"));
}
}