Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests began failing after moving to new environment #8148

Closed
dmoon-kdg opened this issue Feb 23, 2024 · 4 comments
Closed

Tests began failing after moving to new environment #8148

dmoon-kdg opened this issue Feb 23, 2024 · 4 comments
Assignees
Labels
SYSTEM: native automation TYPE: bug The described behavior is considered as wrong (bug).

Comments

@dmoon-kdg
Copy link

What is your Scenario?

I am in the process of moving my TestCafe test scripts to a new laptop, so I am pretty much doing the environment installation from scratch. I am seeing different behavior on the two machines. The most significant one is that tests that involve clicking on a link, which worked previously, are failing even though the link is recognized as being visible. Clicking on button elements, so far, seems to be fine.

What is the Current behavior?

As I watch the test execute, I see the cursor move toward the link element, but nothing actually happens, and the test fails when either checking the url after clicking the link or attempting to interact with elements on the next page.

What is the Expected behavior?

I expected full backward compatibility, in this specific case being able to click on link elements.

What is the public URL of the test page? (attach your complete example)

https://app.forgeos.co/login

What is your TestCafe test code?

import { Selector, t } from 'testcafe'
import { ClientFunction } from 'testcafe'

let emailField = Selector('input').withAttribute('placeholder', 'Enter your email')
let passwordField = Selector('input').withAttribute('placeholder', 'Enter your password')

let loginButton = Selector('button').withText('Login')
let forgotButton = Selector('a').withText('Forgot your password?')
let backToLogin = Selector('a').withText('Back to Login')
let errorBanner = Selector('.alert.alert-danger').child()
let forgotPasswordInput = Selector('label').withText('Email').nextSibling()
let resetButton = Selector('button').withText('Send Password Reset Link')
let getLocation = ClientFunction(() => document.location.href)
let successBanner = Selector('.alert.alert-success')

async function enterCredentials( inputEmail, inputPassword ) {
let tempEmail = inputEmail.toString()
let tempPassword = inputPassword.toString()
await t
.typeText(emailField, tempEmail)
.typeText(passwordField, tempPassword)
}

const TEST_DESCRIPTION = 'logins'

fixture`login_and_forgotpassword`
    .page `https://app.forgeos.co/login`


test(`${TEST_DESCRIPTION} | login page header | C2356 `, async t => {
    let imageElement = Selector('img')
	let imageSource = await imageElement.getAttribute('src')
    await t.expect(imageSource).contains('/forgeos_logo.svg')
})

test(`${TEST_DESCRIPTION} | login page available controls | C2357 `, async t => {
     await t
        .expect(emailField.exists).eql(true)
        .expect(passwordField.exists).eql(true);

    //confirm there is a button with the text 'Login'
    let testElement = Selector('button').withText('Login');
    await t.expect(testElement.exists).eql(true);

    //Confirm there is a button with the text 'Forgot Your Password?'
    testElement = Selector('.btn.btn-default').withText('Forgot your password?')
    await t.expect(forgotButton.visible).eql(true);

    await t
        .expect(Selector('label').withExactText('Remember Me').exists).eql(true)
})

test(`${TEST_DESCRIPTION} | attempt login without email and password | C2358 `, async t => {
    await t
       .click(loginButton);

    const emailMsgElement = Selector('.alert-danger').child().child().withText('The email field is required.');
    await t.expect(getLocation()).contains('/login')


    const pwdMsgElement = Selector('.alert-danger').child().child().withText('The password field is required.');
    await t
        .expect(getLocation()).contains('/login')
})

test(`${TEST_DESCRIPTION} | password reset page layout | C2364 `, async t => {
    await t.expect(forgotButton.visible).eql(true)   
    await t.click(Selector('a').withAttribute('href','/password/reset'))
    await t
      .expect(getLocation()).contains('/password/reset');

  await t
      .expect(Selector('.form-control').nth(4).prevSibling().innerText).eql("Email");

  
  await t.expect(resetButton.visible).eql(true);

  await t.expect(backToLogin.visible).eql(true);

   await t
      .expect(Selector('.panel-heading').innerText).eql("Password Reset Request");
})

Your complete configuration file

N/A

Your complete test report

Running tests in:

  • Chrome 122.0.0.0 / Windows 11

login_and_forgotpassword
√ logins | login page header | C2356
√ logins | login page available controls | C2357
√ logins | attempt login without email and password | C2358
× logins | password reset page layout | C2364

  1. AssertionError: expected 'https://app.forgeos.co/login' to include '/password/reset'

    Browser: Chrome 122.0.0.0 / Windows 11

    66 |
    67 | test(${TEST_DESCRIPTION} | password reset page layout | C2364 , async t => {
    68 | await t.expect(forgotButton.visible).eql(true)
    69 | await t.click(Selector('a').withAttribute('href','/password/reset'))
    70 | await t

    71 | .expect(getLocation()).contains('/password/reset');
    72 |
    73 | await t
    74 | .expect(Selector('.form-control').nth(4).prevSibling().innerText).eql("Email");
    75 |
    76 |

    at (c:\QA_Regression\ForgeOS\dci-testing\Automation\24_Login\sample.js:71:34)
    at asyncGeneratorStep (c:\QA_Regression\ForgeOS\dci-testing\Automation\24_Login\sample.js:1:39)
    at _next (c:\QA_Regression\ForgeOS\dci-testing\Automation\24_Login\sample.js:1:39)

1/4 failed (7s)

Screenshots

No response

Steps to Reproduce

TestCafe version

3.5.0

Node.js version

20.11.1

Command-line arguments

testcafe chhrome sample.js

Browser name(s) and version(s)

Chrome 122.0.6261.58

Platform(s) and version(s)

Windows 11 Business, Version 20.0.33631

Other

The test environment in which the script is successful:
TestCafe: 2.0.1
Node: 14.20.1
Browser: Chrome 121.0.6167.140
OS: Windows 11 Pro, version 23H2

@dmoon-kdg dmoon-kdg added the TYPE: bug The described behavior is considered as wrong (bug). label Feb 23, 2024
@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Feb 23, 2024
@Makavelic
Copy link

Wonder if this is related to #8145?

@dmoon-kdg
Copy link
Author

It may be somewhat related. I don't recall having any issues with running headless. Some of the tests did complete successfully, but anything that relied on clicking on an element failed, but always after the point of clicking that link.

@Bayheck
Copy link
Collaborator

Bayheck commented Feb 27, 2024

We appreciate you taking the time to share information about this issue. We reproduced the bug and added this ticket to our internal task queue. We'll update this thread once we have news.

As a workaround, you could try disabling Native Automation mode. I managed to run your tests successfully with the
--disable-native-automation flag.

@Bayheck Bayheck added STATE: Issue accepted An issue has been reproduced. and removed STATE: Need response An issue that requires a response or attention from the team. labels Feb 27, 2024
@DevExpress DevExpress deleted a comment from github-actions bot Feb 27, 2024
@aleks-pro aleks-pro added SYSTEM: native automation and removed STATE: Issue accepted An issue has been reproduced. labels Feb 28, 2024
@Bayheck Bayheck self-assigned this Mar 6, 2024
@Bayheck
Copy link
Collaborator

Bayheck commented Mar 13, 2024

Hello,

I researched this issue, and it turned out to be an interesting case with the link on your page.

The text of your link is divided into 2 lines.

Between them, there is a blind layer of the label, which is not interactive. You can check this on your own - click this spot.

image

By default,

t.click(Selector('a').withAttribute('href','/password/reset'))

clicks the center of your Selector. In your case, right in this blind spot.

image

So, in order to click right on the link, you should add an offsetY option to your click call.

An example that worked for me:

await t.click(Selector('a').withAttribute('href','/password/reset'), { offsetY: 5 })

https://testcafe.io/documentation/402710/reference/test-api/testcontroller/click#options

@Bayheck Bayheck closed this as completed Mar 13, 2024
@need-response-app need-response-app bot added STATE: Need response An issue that requires a response or attention from the team. and removed STATE: Need response An issue that requires a response or attention from the team. labels Mar 13, 2024
Aleksey28 pushed a commit that referenced this issue Jun 3, 2024
<!--
Thank you for your contribution.

Before making a PR, please read our contributing guidelines at

https://github.com/DevExpress/testcafe/blob/master/CONTRIBUTING.md#code-contribution

We recommend creating a *draft* PR, so that you can mark it as 'ready
for review' when you are done.
-->

## Purpose
Testcafe did not click properly on multiline elements.

## Approach
In testcafe-hammerhead replaced getBoundingClientRect with
getClientRects.

Fix Edge workflow tests
#8189

## References
#8179
#8148

Hammerhead PR:
DevExpress/testcafe-hammerhead#3004


## Pre-Merge TODO
- [x] Write tests for your proposed changes
- [ ] Make sure that existing tests do not fail

---------

Co-authored-by: Bayheck <adil.rakhaliyev@devexpress.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
SYSTEM: native automation TYPE: bug The described behavior is considered as wrong (bug).
Projects
None yet
Development

No branches or pull requests

4 participants