1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Webdriver & Wordpress Issues

Discussion in 'Programming' started by judaculla, Sep 4, 2016.

  1. judaculla

    judaculla Jr. VIP Jr. VIP

    Joined:
    Oct 11, 2014
    Messages:
    325
    Likes Received:
    119
    Location:
    USA
    Does anyone have any experience posting content to wordpress.com (the free kind of wordpress, not self-hosted) websites with Webdriver?

    I'm having some issues that I don't know how to diagnose.

    I can post some content without any issue. However, when the content seems to be longer (which is what needs to happen) there seems to be a very odd issue. The UI of wordpress.com's editor kind of freezes up, scrolls down, and then actually posts what content has been entered so far. Additionally, it seems to trigger some sort of pop-up dialog box to ? switch users maybe ?.

    I've tried to split the content up into smaller blocks, posting only 50-100 chars at a time, then waiting, and it seems to help ...some but still causes issues.

    If anyone has any insight into this issue, or would be willing to share their general approach, I'd be much appreciative.

    UPDATED:

    I can copy/paste the content into Wordpress.com with webdriver—and there is no issue with the content appearing. (There is a lot of issues doing it this way IMO though)

    I'm pretty unfamiliar with Webdriver, but it seems that it sends large blocks of text in smaller chunks, while doing something between blocks. I think that 'something' it's doing is causing my issue.
     
    Last edited: Sep 4, 2016
  2. ekapek

    ekapek Jr. VIP Jr. VIP Premium Member

    Joined:
    Aug 2, 2010
    Messages:
    266
    Likes Received:
    47
    Home Page:
    Try set it with execute javascript
     
  3. judaculla

    judaculla Jr. VIP Jr. VIP

    Joined:
    Oct 11, 2014
    Messages:
    325
    Likes Received:
    119
    Location:
    USA
    I've little experience with the Webdriver API, is the following code similar to what you recommend?

    Code:
    element = driver.find_element_by_css_selector('#my_element')
    
    driver.execute_script('arguments[0].setAttribute(''my-text)', element)
    
    Assuming the
    Code:
     element 
    variable has value set via js on page?

    I'm pulling this from here
     
  4. ekapek

    ekapek Jr. VIP Jr. VIP Premium Member

    Joined:
    Aug 2, 2010
    Messages:
    266
    Likes Received:
    47
    Home Page:
    It can be somthing like yours but use "value" directly for arguments[0] or try with:

    Code:
    driver.execute_script("document.getElementById('my_element').value = 'my_text';")
     
    • Thanks Thanks x 1
  5. judaculla

    judaculla Jr. VIP Jr. VIP

    Joined:
    Oct 11, 2014
    Messages:
    325
    Likes Received:
    119
    Location:
    USA
    Thanks, that approach seems more straight forward.
     
  6. Emma Clark

    Emma Clark Newbie

    Joined:
    Aug 3, 2016
    Messages:
    21
    Likes Received:
    3
    Location:
    California
    Home Page:
    Execute java-script!
     
    • Thanks Thanks x 1
  7. judaculla

    judaculla Jr. VIP Jr. VIP

    Joined:
    Oct 11, 2014
    Messages:
    325
    Likes Received:
    119
    Location:
    USA
    Thanks, ive been realizing thats the approach needed in a lot of wedriver necessitating situations!