在不指定python selenium webdriver中的元素的情况下发送密钥 [英] Send keys without specifying element in python selenium webdriver

查看:121
本文介绍了在不指定python selenium webdriver中的元素的情况下发送密钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个页面,其源代码不可用,但是有一个输入框,光标闪烁.

I have a page whose source code is not available, but there is a input box where cursor is blinking.

我可以在没有找到元素的情况下将一些内容写到文本框中吗?我的意思是,通过某种方式,发送键可以自动查找聚焦的输入框并输入输入内容.

Can i write something into the text box without finding the element. I mean, some way where send key can automatically look for focussed inputbox and type input to it.

我的代码无法正常工作

driver.send_keys("testdata")

推荐答案

解决了

from selenium.webdriver.common.action_chains import ActionChains
actions = ActionChains(self.driver)
actions.send_keys('dummydata')
actions.perform()

这篇关于在不指定python selenium webdriver中的元素的情况下发送密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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