简体   繁体   中英

Javascript box not being triggered in selenium

I'm currently trying to automate part of our web application, mainly a form of @mentioning similar to facebook. In the front end when a user types @ into a text input the API calls the list of users and displays them in a box that appears. This element is currently at the end of the DOM and not visible until the javascript triggers when the @ is typed.

My selenium code uses send_keys to populate the @namehere but the user window element doesn't appear, even if i do it manually while the browser is opened via selenium

I've tried using the upkey event from Action Chains, injecting javascript to trigger the event, clicking back onto the text input to make sure its focused but nothing works. This happens in both chrome and firefox

Literally searched everywhere, any ideas?

Feature step:

And i create a post titled "@James"

implementation:

@when('i create a post titled "([^"]*)"')
    def step_impl(context, text):
    page = ActivityStreamPage.NewPost(context)
    page.post_input.click()
    page.post_input.send_keys(text)

element:

'post_input': (By.CLASS_NAME, "js-post-textarea")

web element:

<div class="js-post-textarea js-edit-content editor__editable" 
contenteditable="true" autocomplete="off" autocorrect="off" 
autocapitalize="off" placeholder="Write a post or @mention to notify 
someone"><span class="atwho-query">@</span><br></div>

user box:

<div class="atwho-view" id="at-view-64" style="display: none; top: 
    135px; left: 440px;">
    <ul class="atwho-view-ul">
        <li class="mention__item cur">
            <p class="mention__notice">
                <span>@Group</span>
                "Notify everyone in this Group."
            </p>    
        </li>
    </ul>
</div>

after a lot of debugging, seems that the AJAX call was being refused due to permissions. a defect with the application rather than selenium.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM