问题
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")
回答1:
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)
来源:https://stackoverflow.com/questions/47136239/entering-text-to-span-selenium-python