Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

434
Views
react-datepicker - cannot open date popup using Testcafe

I'm using the react-datepicker package as a custom Date Picker component for my app. I wrap it in my own component like so:

const MyCustomDatePicker = ({ onChange, value, error, disabled, placeholder, dateFormat }) => {
  return (
    <div className='date-input' data-test-id='date-picker'>
      <div className='date-input__field'>
        <DatePicker
          selected={value}
          disabled={disabled}
          onChange={onChange}
          dateFormat={dateFormat}
          placeholderText={placeholder}
          className='date-input__input'
        />
      </div>
    </div>
  );
};

Which works fine in the UI, I can select a date from the popup:

Popup

However, when I try replicating this in Testcafe, I can't seem to get the popup to appear. I've tried a different combination of my own class names and those generated by the react-datepicker package:

import { Selector } from 'testcafe';

fixture`Getting Started`
  .page`https://my-page`;

test('My first test', async t => {
  await t.click(Selector('date-input__input'))
  await t.click(Selector('react-datepicker__input-container'))
  await t.click(Selector('react-datepicker-wrapper'))
  await t.wait(5000)
});

But none of these open the date picker popup. Is it possible to do this in testcafe?

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

In the snippet you provided, I see an error: you are trying to take a selector by class, but you are not using a dot. Try, for example, running this test:

import { Selector } from 'testcafe';

fixture `New Fixture`
    .page `https://reactdatepicker.com/`;
    
test(`New Test`, async t => {
    const anyPicker = Selector('.react-datepicker__input-container').nth(1);
    const input     = anyPicker.find('input');
    const dateCell  = Selector('.react-datepicker__day').withText('16');

    await t
        .click(input)
        .click(dateCell)
        .expect(input.value).eql('07/16/2022');
});
about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!