0
我正在通过使用硒dll's网页刮。但我刮脸时记录清单的问题。如果我使用调试器,它将提取所有记录,但是如果禁用调试器并运行应用程序,它有时会显示较少的记录或某个时间显示没有记录。我想知道是否有任何方法可以知道页面是否已完全加载。硒刮在c#
driver.FindElementsByClassName( “搜索结果 - GridView的项目”)。ToList()
改变记录数。
driver.FindElementsByClassName("search-result-gridview-item").ToList().ForEach(x =>
{
objUPCProcess = new UPCProcessingModel();
try
{
objUPCProcess.Description = x.FindElement(By.ClassName("prod-ProductTitle")).Text;
objUPCProcess.Price = x.FindElement(By.ClassName("Price")).Text;
listOfProductDetails.Add(objUPCProcess);
if (i == 0)
{
log.Item = objUPCProcess.Description;
i++;
}
}
catch (OpenQA.Selenium.NoSuchElementException ex)
{
try
{
objUPCProcess.Description = x.FindElement(By.ClassName("prod-ProductTitle")).Text;
objUPCProcess.Price = ex.Message;
listOfProductDetails.Add(objUPCProcess);
}
catch
{
try
{
objUPCProcess.Price = x.FindElement(By.ClassName("Price")).Text;
objUPCProcess.Description = ex.Message;
listOfProductDetails.Add(objUPCProcess);
}
catch
{
objUPCProcess.Description = ex.Message;
objUPCProcess.Price = ex.Message;
log.Message = ex.Message;
listOfProductDetails.Add(objUPCProcess);
log.Status = "Error";
}
}
}
});
}