How do you test a reactjs web app with selenium?

后端 未结 2 1092
感动是毒
感动是毒 2021-02-15 15:48

I have a web app using React and I\'m trying to create some tests using Selenium RC. I\'m finding though that when Selenium changes the values of fields, events are not properly

相关标签:
2条回答
  • 2021-02-15 16:16
    import ReactTestUtils from 'react-addons-test-utils'    // ES6
    var ReactTestUtils = require('react-addons-test-utils') // ES5 with npm
    var ReactTestUtils = React.addons.TestUtils;            // ES5 with react-with-addons.js
    

    wrap that in a python library and load it in RF...
    Hopefully it will work.

    0 讨论(0)
  • 2021-02-15 16:28

    Try Simulate in the React TestUtils addon:

    React.addons.TestUtils.Simulate.change(document.getElementById('your-id-here'))
    

    See http://facebook.github.io/react/docs/test-utils.html#simulate

    It also requires that you switch to the React file containing the addons:

    "To get the add-ons, use react-with-addons.js (and its minified counterpart) rather than the common react.js." — http://facebook.github.io/react/docs/addons.html

    0 讨论(0)
提交回复
热议问题