尝试获取 WatiN 的链接/浏览器
我最近开始测试和使用 WatiN,遇到了一些我无法真正解决的问题/错误。
首先我会描述我正在做的测试.. 我将去获取列表中特定 div 中的所有链接...所以我有一个链接列表...我将循环遍历... 在循环中,我将使用 link.clicknowait() 函数来打开该链接(它在新的 ie 选项卡中打开)..然后我使线程休眠几秒钟,然后通过将该链接(url)附加到关闭该浏览器一个新的浏览器,之后浏览器关闭,因为我总是使用“using (..)”语句来使用它。
所以第一个问题是,当浏览器获取所有链接并开始单击它们时,其中一个链接可能会导致不正确的页面,这意味着它可能会导致一个页面说页面不再存在,所以在那之后我不能不再关闭该页面...如何解决此问题并攻击 ie 到不存在的页面? 它没有固定的网址...您可以推荐什么吗?
是否有类似“尝试附加到...”的方法,否则如果它尝试攻击浏览器到不存在的链接,我会收到错误。
还有无论如何要检查链接列表中的链接是否仍然是正确的,因为我也有几次例外,它无法单击该链接,因为它在页面中为空...... 或者我可以检查诸如 link.trytoclick() 之类的内容,如果出现错误,则忽略该链接并进一步进行操作???
单击大量链接并打开和关闭浏览器后的最后一个问题,我收到错误 outofmemoryexception ..怎么可能,我使用了“using 语句”,它总是在浏览器超出时关闭浏览器...
提前致谢寻求帮助。
I've recently started to test and use WatiN, and i came across some of problems/errors that i cant really solve.
First ill describe what i'm doing with my tests ..
I'll go and get all the links in a specific div in a list ... so i have a link lists ... which im gonna loop thru ...
In the loop im gonna use a link.clicknowait() function, to open that link (it opens in a new ie tab) .. then i sleep thread for like few seconds and i close that browser by attaching that link (url) to a new browser and after that the browser is closed as im using it always with 'using (..)' statement.
So the first problem is that when the browser gets all the links and start to click them one of the links might lead not the right page, meaning like it can lead to a page that is saying page doenst exist anymore, so after that i cant close that page anymore ... how to solve this and attack ie to that not existing page?
It hasnt got fixed url ... anything that you can recommend?
Is there a method something like "Try attach to ...." because else i get an error if it tries to attack a browser to a link which doesnt exist.
Also is there anyway to check if the link in a links list is still the right one, cuz i also had an exeption few times that it couldnt click on that link because it was empty in the page ...
Or can i check something like link.trytoclick() and if an error and just ignores that link and goes further ???
And the last question after clicking alot of links and opening and closing browser i got an error outofmemoryexception .. how can it be, i've used 'using statement' which always closed browser when it was out of it ...
Thanks in advance for the help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 href 在 watin 会话的同一窗口中打开链接,验证链接后您可以返回原始页面。
像这样的事情:
要检查链接是否存在,请使用:
You can use the href to open the link in the same window of your watin session, after you verify the link you can go back to original page.
Some thing like this:
To check if the link exists use: