输入文本以跨越Selenium/Python [英] Entering text to span Selenium/Python

查看:79
本文介绍了输入文本以跨越Selenium/Python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试输入要代替"SAMPLE TEXT"的文本.我正在使用Selenium/Python,但不能使用send_keys方法.您还有其他想法吗? 我将屏幕截图附加了HTML和应用程序的屏幕截图

I try to enter text to span in place of "SAMPLE TEXT". I'm using Selenium/Python but I can't do it using send_keys method. Do you have any other ideas how can I do that? I attached screenshots with HTML and screenshot from app

我尝试使用该代码,但不起作用:

I tried to use that code, but doesnt work:

body = driver.find_element_by_xpath('//*[@id="oss-view-wrapper"]/main/div/div/div[2]/div/div[2]/div[1]/div/div/div[2]/div/div/div[2]/div/div[2]/div[2]/div/div/div/div[2]/div/div/div/div/div/div[6]/div[1]/div/div/div/div[5]/div/pre/span')
body.send_keys("TEST")

推荐答案

您可以为此使用javasecriptExceutor,请立即检查代码,因为我对Python并不了解:

You can use javasecriptExceutor for that, Please chech code at once i am not have deep knowledge of Python:

element = driver.find_element_by_xpath('Your xpath')
driver.execute_script("arguments[0].innerText = 'test'", element)

这篇关于输入文本以跨越Selenium/Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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