protractor icon indicating copy to clipboard operation
protractor copied to clipboard

Protractor for React Applications

Open mangeshkhaire14 opened this issue 7 years ago • 5 comments

Hi,

Can I use Protractor with Jasmine for testing React applications(Widget based application). will it be difficult to maintain protractors test for long run projects?

Thanks, Mangesh

mangeshkhaire14 avatar Feb 25 '19 08:02 mangeshkhaire14

You can do it for sure. Just don't wait for Angular add in protractor config in the onPrepare block:

onPrepare: async () => {
  ...
  await browser.waitForAngularEnabled(false);
  ...
}

CrispusDH avatar Feb 25 '19 09:02 CrispusDH

Thank you

mangeshkhaire14 avatar Feb 25 '19 10:02 mangeshkhaire14

sort of specific question better to ask on Stack Overflow.

CrispusDH avatar Feb 25 '19 11:02 CrispusDH

Can anyone share basic protractor - Cucumber BDD framework for React application

86SUSHIL avatar Mar 19 '19 06:03 86SUSHIL

@mangeshkhaire14,

You can try out Protractor-React-Selector!

protractor-react-selector is a lightweight plugin to help you to locate web elements in your REACT app using props and states.

You need to use React Dev Tool to identify the component names in that case.

Here is an example:

Suppose your react app:

const MyComponent = ({ someBooleanProp }) => (
  <div>My Component {someBooleanProp ? 'show this' : ''} </div>
)
 
const App = () => (
  <div id='root'>
    <MyComponent />
    <MyComponent someBooleanProp={true} />
  </div>
)
 
ReactDOM.render(<App />, document.getElementById('root'))

Then you can simply identify the react element like:

element(by.react('MyComponent', { someBooleanProp: true }))

If you want to check out some amazing examples, visit here

Hope it will help!

abhinaba-ghosh avatar Oct 19 '19 18:10 abhinaba-ghosh