2012-01-17 58 views
4

在我们的网页aplication文本,我们使用多个警报这样的:正从文本框在警报

enter image description here

我需要从这个警报检索链接。 我所做的:

Alert alert = driver.switchTo().alert(); 
String link = alert.getText(); 

alert.getText()返回“链接复制”,在文本框不是一个链接 这样?我怎样才能在这种情况下链接?

+0

可能您需要先获取文本框? 请参阅http://stackoverflow.com/questions/5164894/selenium2-and-webdriver-alert – Reddy 2012-01-17 11:14:27

+0

我不知道如何从alert中获取文本框。 – biomaks 2012-01-17 12:03:15

+0

你可以尝试driver.findElement作为OP中使用的问题,我已经链接? – Reddy 2012-01-17 12:30:56

回答

0

WebDriver将无法检索链接文本。 对于Windows,您可以利用Windows自动化API刮取文本,其他操作系统可能具有您可以使用的类似API - 但简短的回答是WebDriver无法执行此操作。