J'ai une page HTML et créé les objets de page de cette page. Cette page contient une table html dynamique. Je ne peux pas l'utiliser en tant qu'objets de page car il est créé dynamiquement. Je veux utiliser n'importe quelle ligne et colonne de la page dans mes cas de test.Comment gérer les tables html dynamiques dans un modèle d'objet page en utilisant la page fatory en sélénium?
page classe Object:
public final class AgentsPage
{
@FindBy(how=How.XPATH, using="//table[@id='gwt-debug-com.seamless.ers.client.agentPortal.client.view.screens.SubAgentsReportScreen']//input[@id='gwt-debug-Phone_Number']")
public WebElement phoneNumber;
public String getTextOfPhoneNumber()
{
return phoneNumber.getAttribute("value");
}
public void setTextForPhoneNumber(String value)
{
phoneNumber.clear();
phoneNumber.sendKeys(value);
}
@FindBy(how=How.XPATH, using="//table[@id='gwt-debug-com.seamless.ers.client.agentPortal.client.view.screens.SubAgentsReportScreen']//input[@id='gwt-debug-Name']")
public WebElement name;
public String getTextOfName()
{
return name.getAttribute("value");
}
public void setTextForName(String value)
{
name.clear();
name.sendKeys(value);
}
@FindBy(how=How.XPATH, using="//table[@id='gwt-debug-com.seamless.ers.client.agentPortal.client.view.screens.SubAgentsReportScreen']//input[@id='gwt-debug-Reseller_ID']")
public WebElement resellerId;
public String getTextOfResellerId()
{
return resellerId.getAttribute("value");
}
public void setTextForResellerId(String value)
{
resellerId.clear();
resellerId.sendKeys(value);
}
@FindBy(how=How.XPATH, using="//table[@id='gwt-debug-com.seamless.ers.client.agentPortal.client.view.screens.SubAgentsReportScreen']//input[@id='gwt-debug-Terminal_Serial']")
public WebElement terminalSerial;
public String getTextOfTermialSerial()
{
return terminalSerial.getAttribute("value");
}
public void setTextForTerminalSerial(String value)
{
terminalSerial.clear();
terminalSerial.sendKeys(value);
}
@FindBy(how=How.XPATH, using="//table[@id='gwt-debug-com.seamless.ers.client.agentPortal.client.view.screens.SubAgentsReportScreen']//select[@id='gwt-debug-Rows_Per_Page']")
public WebElement rowsPerPage;
public String getSelectedValueOfRowsPerPage()
{
Select select=new Select(rowsPerPage);
return select.getFirstSelectedOption().getText();
}
public void setValueForRowsPerPage(String visibleText)
{
if(!(visibleText.equals("")||visibleText==null))
{
Select select=new Select(rowsPerPage);
select.selectByVisibleText(visibleText);
}
}
public void setValueForRowsPerPage(int index) throws Exception
{
Select select=new Select(resellerId);
select.selectByIndex(index);
}
@FindBy(how=How.XPATH, using="//table[@id='gwt-debug-com.seamless.ers.client.agentPortal.client.view.screens.SubAgentsReportScreen']//button[@id='gwt-debug-submit_button']")
public WebElement submit;
public String getTextOfSubmit()
{
return submit.getText();
}
@FindBy(how=How.XPATH, using="//table[@id='gwt-debug-com.seamless.ers.client.agentPortal.client.view.screens.SubAgentsReportScreen']//button[@id='gwt-debug-clear_button']")
public WebElement reset;
public String getTextOfReset()
{
return reset.getText();
}
@FindBy(how=How.XPATH, using="//table[@id='gwt-debug-com.seamless.ers.client.agentPortal.client.view.screens.SubAgentsReportScreen']//button[@id='gwt-debug-nextPage']")
public WebElement next;
public String getTextOfNext()
{
return next.getText();
}
@FindBy(how=How.XPATH, using="//table[@id='gwt-debug-com.seamless.ers.client.agentPortal.client.view.screens.SubAgentsReportScreen']//button[@id='gwt-debug-prevPage']")
public WebElement previous;
public String getTextOfPrevious()
{
return previous.getText();
}
@FindBy(how=How.XPATH, using="//table[@id='gwt-debug-com.seamless.ers.client.agentPortal.client.view.screens.SubAgentsReportScreen']//button[@id='gwt-debug-lastPage']")
public WebElement last;
public String getTextOfLast()
{
return last.getText();
}
@FindBy(how=How.XPATH, using="//table[@id='gwt-debug-com.seamless.ers.client.agentPortal.client.view.screens.SubAgentsReportScreen']//button[@id='gwt-debug-firstPage']")
public WebElement first;
public String getTextOfFirst()
{
return first.getText();
}
@FindBy(how=How.XPATH, using="//table[@id='gwt-debug- com.seamless.ers.client.agentPortal.client.view.screens.SubAgentsReportScreen']//div[contains(text(),'Page:') and contains(text(),'/')]")
public WebElement pageCount;
public String getTextOfPageCount()
{
return pageCount.getText();
}
//Need page objects for the dynamic html table
}
[Page Image] [1]: http://i.stack.imgur.com/o94F0.png
Je ne veux pas utiliser un XPath ou des boucles pour itérer lignes de la table dans mon cas de test. Je veux juste l'utiliser comme tout autre élément d'objet de page statique comme le bouton AgentsPage.submit. Comment cela peut il etre accompli?
Merci pour l'aide. J'apprécie beaucoup. –