在Selenium 1.x或2.x中是否有任何方法可以滚动浏览器窗口,以便XPath识别的特定元素可以在浏览器中查看?Selenium中有一个焦点方法,但它似乎没有在FireFox中物理滚动视图.有没有人对如何做到这一点有任何建议?
我需要这个的原因是我正在测试页面上元素的点击.不幸的是,除非元素可见,否则事件似乎不起作用.我无法控制单击该元素时触发的代码,因此我无法对其进行调试或修改,因此,最简单的解决方案是将项目滚动到视图中.
我正在尝试序列化/反序列化一个Dictionary<string, object>似乎工作正常,如果对象是一个简单的类型但在对象更复杂时不起作用.
我有这门课:
public class UrlStatus
{
public int Status { get; set; }
public string Url { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
在我的词典中,我添加了一个List<UrlStatus>带有"Redirect Chain"键和一些带有"Status","Url","Parent Url"键的简单字符串.我从JSON.Net回来的字符串如下所示:
{"$type":"System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[System.Object, mscorlib]], mscorlib","Status":"OK","Url":"http://www.ehow.com/m/how_5615409_create-pdfs-using-bean.html","Parent Url":"http://www.ehow.com/mobilearticle35.xml","Redirect Chain":[{"$type":"Demand.TestFramework.Core.Entities.UrlStatus, Demand.TestFramework.Core","Status":301,"Url":"http://www.ehow.com/how_5615409_create-pdfs-using-bean.html"}]}
Run Code Online (Sandbox Code Playgroud)
我用来序列化的代码如下:
JsonConvert.SerializeObject(collection, Formatting.None, new JsonSerializerSettings
{
TypeNameHandling = TypeNameHandling.Objects,
TypeNameAssemblyFormat = System.Runtime.Serialization.Formatters.FormatterAssemblyStyle.Simple
});
Run Code Online (Sandbox Code Playgroud)
反序列化我正在做:
JsonConvert.DeserializeObject<T>(collection, new JsonSerializerSettings
{
TypeNameHandling = TypeNameHandling.Objects,
TypeNameAssemblyFormat = System.Runtime.Serialization.Formatters.FormatterAssemblyStyle.Simple,
});
Run Code Online (Sandbox Code Playgroud)
字典返回正常,所有字符串都返回正常,但List没有正确反序列化.它刚回来了
{[
{
"$type": "XYZ.TestFramework.Core.Entities.UrlStatus, XYZ.TestFramework.Core",
"Status": 301,
"Url": "/how_5615409_create-pdfs-using-bean.html"
}
]}
Run Code Online (Sandbox Code Playgroud)
当然我可以再次取消这个字符串,我得到了正确的对象,但似乎JSON.Net应该为我做这个.显然,我做错了什么,但我不知道它是什么.