简体   繁体   English

如何在selenium webdriver中关闭语言选项框架

[英]How to close language option frame in selenium webdriver

I want to skip the language selection through Selenium Webdriver. 我想通过Selenium Webdriver跳过语言选择。 This could be by pressing escape from keyboard or clicking on the save button. 这可以通过按键退出键盘或单击保存按钮。 I am failing to do either of these. 我没有做到这两件事。 Can anyone help in this regard ? 在这方面有人可以提供帮助吗?

//driver.switchTo().alert();
//button[@id='save_language']

在此输入图像描述

It's more like an alert. 这更像是一个警报。

Try with this code : 试试这段代码:

Alert a =  driver.switchTo().alert();
a.accept();  

After accepting the alert, you will have to switch back the focus of web driver to default. 接受警报后,您必须将Web驱动程序的焦点切换回默认值。 For that you will need : 为此你需要:

driver.switchTo().defaultContent();

Try using Actions class,which is basically used for input interactions (Ex: Keyboard and mouse interactions) You need to import following package for it. 尝试使用Actions类,它基本上用于输入交互(例如:键盘和鼠标交互)您需要为它导入以下包。

import org.openqa.selenium.interactions.Actions;

Then create a Actions class object and use it to send escape keys. 然后创建一个Actions类对象并使用它来发送转义键。

Actions action=new Actions(driver);
action.sendKeys(Keys.ESCAPE).build().perform();

Hope it helps ! 希望能帮助到你 !

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM