硒如何单击Ctrl + p [英] Selenium how to click Ctrl + p

查看:71
本文介绍了硒如何单击Ctrl + p的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要打开打印窗口.我已经使用了下面的代码,但是它不起作用.

I need to open the print window. I have used below code but it's not working.

Keys. Chord(Keys.CONTROL,"p")

我使用了另一种方法来单击随机元素,并在下面的代码中使用了.

I have used another way to click on a random element and used below code.

Driver. findElement(By.id("something")).sendKeys(Keys.Control +"p")

两者都不起作用.要求为此提供建议.

Both are not working. Request to provide the suggestion for this.

推荐答案

能否指定您的Web浏览器?

Could you please specify your web browser?

.sendKeys和Actions都无法使用.

Any way .sendKeys and Actions are not work.

但是您可以使用 JavaScriptExecutor 在任何浏览器中获取打印消息:

But you can get print message in any browser using JavaScriptExecutor:

 ((JavascriptExecutor)driver).executeScript("window.print()");

这篇关于硒如何单击Ctrl + p的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆