1

I need to add multiple h2 titles but in WordPress Classic Editor the h2 titles show up only like that - this is how the code looks

there are no identifiers

The code now

   driver.switch_to.default_content()
driver.find_element(By.XPATH,'/html/body/div[1]/div[2]/div[3]/div[1]/div[3]/form/div/div/div[1]/di v[4]/div/div[2]/div[2]/div/div[1]/div/div/div/div[1]/div/div/div/div[1]/button').click()
    time.sleep(1)
    
WebDriverWait(driver, 20).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH,"/html/body/div[1]/div[2]/div[3]/div[1]/div[3]/form/div/div/div[1]/div[4]/div/div[2]/div[2]/div/div[2]/iframe")))
    driver.send.keys('text')

IDK why the code looks weird like that, but now it just adds the h2 title. Since when I add it and it's active is there a way to .send_keys('mt text') but by not clicking on the h2?

1 Answer 1

1

The approach to send text through send_keys() is incorrect here.

send_keys() is a webelement method. So you need to invoke the method on WebElement only.

Your effective code block will be:

WebDriverWait(driver, 20).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH,"/html/body/div[1]/div[2]/div[3]/div[1]/div[3]/form/div/div/div[1]/div[4]/div/div[2]/div[2]/div/div[2]/iframe")))
driver.find_element(By.XPATH,'//body[@id="tinymce" and @data-id="content"]').send.keys('mt text')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.