如果网页上有多个框架,如何选择框架并获取该框架的内容? [英] How to select frame if there are multiple frames on a webpage and get content of that frame?
本文介绍了如果网页上有多个框架,如何选择框架并获取该框架的内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试从具有多个框架的站点名称"yopmail.com"获取电子邮件的内容.我需要切换到框架名称='ifmail',并希望从电子邮件正文中获取文本.
I am trying to get the content of the email from site name "yopmail.com" which is having multiple frames. I need to switch to the frame name = 'ifmail' and want to getText from email body.
请查看yopmail的屏幕截图:
Please see screenshot for yopmail:
任何人都可以在这里帮助我吗?
Anyone can help me out here?
推荐答案
我使用以下代码获取电子邮件正文:
i use the below code to get the text of email body:
Thread.sleep(4000);
driver.switchTo().frame("ifmail");
List<WebElement> elems = driver.findElements(By.cssSelector("div#mailmillieu>div>div[dir='ltr']>div"));
for(WebElement element: elems){
if(!element.getText().equals("")){
System.out.println("body is "+element.getText());
}
}
我使用",因为我的体内有一些br和换行符.但是它将显示您身上的所有文字.
i use "" as there are some br and new line in my body. But it will show all the text of ur body.
这篇关于如果网页上有多个框架,如何选择框架并获取该框架的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文