[英]How can I check if I logged in a website (e.g. LinkedIn) using HtmlUnit?
This is a newbie question in HtmlUnit. 这是HtmlUnit中的一个新手问题。 I have used the code I found on this question to log into LinkedIn, but when I open the page with Chrome the current user is logged out. 我已经使用我在此问题上找到的代码登录LinkedIn,但当我用Chrome打开页面时,当前用户已注销。 Can I check if I have indeed logged in the site? 我可以查看我是否确实已登录该站点?
In general the content of the page somehow changes, when you are logged in. So you could simply log the source of the page after you logged in. (If ajax is used on the page, you need to wait some time so that the javascript can modify the page) 一般情况下,当您登录时,页面的内容会以某种方式发生变化。因此您可以在登录后简单地记录页面的来源。(如果在页面上使用ajax,则需要等待一段时间才能使用javascript可以修改页面)
use the .toXml()
-method to get the html source. 使用.toXml()
- 方法获取html源代码。 You can also save this in a file egthtml and open it in a browser (active content and css will most probably not work, but you can still see enough in most cases to determine, if login worked or what is on the page after the login). 您也可以将其保存在egthtml文件中并在浏览器中打开(活动内容和CSS很可能无法正常工作,但在大多数情况下您仍然可以看到,如果登录有效或登录后页面上有什么内容)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.