Issue
I am trying to select all Text Fields on a webform and delete it. The site is : https://onlinehtmleditor.dev/
w = webdriver.Chrome(executable_path='chromedriver.exe', chrome_options=options)
w.get("https://onlinehtmleditor.dev/")
time.sleep(4)
switch_to_html ='//*[@id="ckeditor-4-output-button"]'
paste_code = '//*[@id="ckeditor-4-output"]/div/div[6]/div[1]/div/div'
element = w.find_element_by_xpath(switch_to_html).click()
time.sleep(2)
# element = w.find_element_by_xpath(paste_code).send_keys("Hi")
clickElement = w.find_element_by_css_selector(".CodeMirror-lines")
time.sleep(1)
clickElement.click()
clickElement.sendKeys(Keys.CONTROL + "a")
clickElement.sendKeys(Keys.DELETE)
Getting Issue in this Line :
clickElement.sendKeys(Keys.CONTROL + "a")
AttributeError: 'WebElement' object has no attribute 'sendKeys'
How to fix this Issue, please guide me
Solution
In Python Selenium the method to send a text to a web element is send_keys
.
sendKeys
is a Java Selenium method.
So instead of
clickElement.sendKeys(Keys.CONTROL + "a")
clickElement.sendKeys(Keys.DELETE)
use
clickElement.send_keys(Keys.CONTROL + "a")
clickElement.send_keys(Keys.DELETE)
Answered By - Prophet
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.