牛骨文教育服务平台(让学习变的简单)
博文笔记

selenium弹出框、页面跳转处理

创建时间:2015-01-14 投稿人: 浏览次数:704
<span style="white-space:pre">		</span>//得到当前窗口的句柄       
		String currentWindow = wd.getWindowHandle();   
		System.out.print(currentWindow);
		//得到所有窗口的句柄       
		Set<String> handles = wd.getWindowHandles();        
		Iterator<String> it = handles.iterator();
		System.out.print("it:"+it);
		while(it.hasNext()){       
			if(currentWindow == it.next())  
				continue;       
			WebDriver  window = wd.switchTo().window(it.next());  
			//获得新窗口,新的webDriver实例。      
			System.out.println("title,url = "+window.getTitle()+","+window.getCurrentUrl());
			window.findElement(By.xpath("//span[text()="确定"]")).click();
			}


声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。