How to call class functions inside cy.origin() #27476
Replies: 3 comments
-
I had this. I could not pass a class POM into the args. What I did was create a .json file with my selectors for this test and passed that in the args. mySelectors.json
Then Import the file into my test, then call my cy.origin code.
|
Beta Was this translation helpful? Give feedback.
-
Got this problem as well where we got POM pattern that we create class for variables and action. I'm stuck with this but i just decided not to use it for cy.origin. Here's an example: UsernamePage.ts class UsernamePage {
//Element Selector or Locator
emailPlaceholderSelector: '[id="loginId"]';
//Page Action
enterEmailId(emailid: string) {
return cy.get(this.emailPlaceholderSelector).type(emailid)
}
}
export default UsernamePage; function loginViaFusionAuth (username: string, password: string) {
cy.visit('/')
cy.origin('https://******/*/**', {args: {username, password }}, ({username, password}) => {
cy.get('[data-test-id="TextInput-Login-Username"]').type(username);
cy.get('#continue').click()
cy.get('#password').type(password);
cy.get('[data-test-id="Button-Login-Login"]').click()
} So when i replace this cy.get('[data-test-id="TextInput-Login-Username"]').type(username); |
Beta Was this translation helpful? Give feedback.
-
I am facing the same issue trying to run class functions inside cy.origin() due to I have redirections as well and domain changes in a login. IT breaks POM approach. Is there any update about it? |
Beta Was this translation helpful? Give feedback.
-
We are trying to automate login to application after redirecting to Key Cloak and entering the login credentials on Key Cloak re-directed page.
We have classes for various functions like an Action class with all the object level functions like enter into a text field and we have separate classes to get the CSS properties of each of the page elements (basically following POM in cypress).
We want to use these class functions inside cy.origin() , but are unable to do so.
How can we import a class inside a .js file and use the class functions inside cy.origin()?
Could you please provide us a way to sort out this issue ?
Thanks !
Beta Was this translation helpful? Give feedback.
All reactions