Java 如何通过Selenium在GWT-LOG中检测新条目?
我正在测试一个使用GoogleWebToolkit(GWT)的网站。特别是,网站会弹出GWT-LOG窗口,其中显示了网站上发生的所有后台活动 我正在编写一些Selenium测试,我需要能够访问GWT-LOG中的条目 现在,我已经通过使用XPath编写了可以占用大量GWT-LOG的代码——我使用上一个和当前的指针来跟踪我上次在GWT-LOG窗口中离开的位置Java 如何通过Selenium在GWT-LOG中检测新条目?,java,gwt,selenium,webdriver,selenium-webdriver,Java,Gwt,Selenium,Webdriver,Selenium Webdriver,我正在测试一个使用GoogleWebToolkit(GWT)的网站。特别是,网站会弹出GWT-LOG窗口,其中显示了网站上发生的所有后台活动 我正在编写一些Selenium测试,我需要能够访问GWT-LOG中的条目 现在,我已经通过使用XPath编写了可以占用大量GWT-LOG的代码——我使用上一个和当前的指针来跟踪我上次在GWT-LOG窗口中离开的位置 /** * Adds each GWT-LOG entry (one line) between "prevXPC" and "curXPC
/**
* Adds each GWT-LOG entry (one line) between "prevXPC" and "curXPC" into an
* ArrayList<String> -- one line per ArrayList index.
*/
public void parseString(ArrayList<String> list) {
// Total count of gwt-log entries
int curXPC = driver.findElements(By.xpath(gwtXPath)).size();
// Empty the ArrayList
list.clear();
// Add elements to the ArrayList between pXPC and cXPC counts
for (int i = prevXPC; i <= curXPC; i++) {
String logEntryXPath = "/html/body/table/tbody/tr[2]/td/div/div/div/div[" + i + "]";
String newEntry = driver.findElement(By.xpath(logEntryXPath)).getText();
list.add(newEntry);
}
prevXPC = (curXPC + 1); // Set the previous XPath count to the current one.
}
/**
*将“prevXPC”和“curXPC”之间的每个GWT-LOG条目(一行)添加到
*ArrayList--每个ArrayList索引一行。
*/
公共空解析字符串(ArrayList列表){
//gwt日志项的总计数
int curXPC=driver.findelelements(By.xpath(gwtXPath)).size();
//清空ArrayList
list.clear();
//将元素添加到pXPC和cXPC计数之间的ArrayList中
对于(int i=prevXPC;我想在GWT中使用“远程日志记录”功能会更容易吗?我需要访问GWT代码吗?因为我在这个网站上没有访问权限。是的,我的建议意味着GWT代码/编译的更改。