onchange event does not get fired on selenium type command

前端 未结 8 2121
予麋鹿
予麋鹿 2020-12-17 21:47

I am typing some value, on change do a total. But somehow, this event is not getting fired with selenium type command.

I also tried typeKey and typeAt ..But no succe

8条回答
  •  鱼传尺愫
    2020-12-17 22:26

    I had a similar problem, with a Dropdown list made with Ajax.
    As the user types in a field, the system displays AJAX divw with several options, each one as a link with target='#'

    And even worse, there was a function called on the onChange() that filled a system flag, and that flag would be used as a validation on the form.submit() (oh, the pain)

    Anyways, my solution for this:
    1 - Selenium sendKeys command so the Ajax div would appear

    
        sendKeys
        id=txtTipoDocumento
        ipsum lorem
    
    

    2 - wait for the link with the expected option to appear

    
        waitForElementPresent
        link=ipsum lorem
        
    
    

    3 - selenium clickAt the link

    
        clickAt
        link=ipsum lorem
        10,20
    
    


    4 - Here is the ONE of the catches: manually fire the onChange() AND blur events. Also, foce the browser to set focus on different field

     
            fireEvent
            id=txtTipoDocumento
            blur
        
        
            fireEvent
            id=selSerie
            change()
        
        
            fireEvent
            id=selSerie
            blur
        
        
            focus
            id=imgDataElaboracao
            
        
    

    5 - Finally, to be sure, I made Selenium do execute the ClickAt() command on the Submit button of the forme, between a mouseDown and MouseUp commands

    
        mouseDown
        id=btnSalvar
        
    
    
        focus
        id=btnSalvar
        
    
    
        clickAt
        id=btnSalvar
        10,20
    
    


    Not elegant, but it worked.

提交回复
热议问题