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

Rerouting with target="_parent" causes "Whoops, there is no test to run" #3121

Closed
jadiaz opened this issue Jan 11, 2019 · 12 comments
Closed
Labels
pkg/https-proxy This is due to an issue in the packages/https-proxy directory stage: ready for work The issue is reproducible and in scope stale no activity on this issue for a long period topic: framebusting topic: 😳 whoops there is no test to run Error msg: "Whoops there is no test to run" type: bug

Comments

@jadiaz
Copy link

jadiaz commented Jan 11, 2019

Current behavior:

test runner returns Whoops, there is no test to run. when clicking a link with selector:
'#sub-menu > ul > :nth-child(5) > a'

Desired behavior:

test passes after link is clicked.

Steps to reproduce: (app code and test code)

app code

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <nav class="navbar navbar-default" id="navTopBar" role="navigation">
        <div></div>
    </nav>
    <footer class="footer">
        <div class="container-fluid">
            <div class="row">
                <div class="privacy-seal"></div>
                <nav id="sub-menu">
                    <ul>
                        <li><a href="AboutUs.htm" target="_parent">About Us</a></li>|
                        <li><a href="faq.html" target="_parent">FAQ</a></li>|
                        <li><a href="ContactUs.htm" target="_parent">Contact Us</a></li>|
                        <li><a href="TermsConditions.htm" target="_parent">Terms and Conditions</a></li>|
                        <li><a href="PrivacyPolicy.htm" target="_parent">Privacy Policy</a></li>
                    </ul>
                </nav>
            </div>
            <div class="row copyright">
                <span class="h6-xs">Copyright 2018.</span>
            </div>
            <div class="social">
                <ul class="social-links">
                    <li class="facebook"><a href="https://www.facebook.com" target="_blank">Facebook</a></li>
                    <li class="instagram"><a href="https://www.instagram.com/" target="_blank">Instagram</a></li>
                    <li class="twitter"><a href="https://twitter.com/" target="_blank">Twitter</a></li>
                </ul>
            </div>
        </div>
    </footer>
</body>

</html>

test code

        it('causes cypress to stop running tests', () => {
            cy.visit('nav-test.html')
            cy.title().should('eq', 'Document')
            cy.get('#sub-menu > ul > :nth-child(5) > a').should('contain', 'Privacy Policy')
            cy.get('#sub-menu > ul > :nth-child(5) > a').click()
            cy.url().should('include', 'PrivacyPolicy')
        })

Versions

Mac OS - Mojave
Cypress v.3.1.4
Google Chrome Version 71.0.3578.98 (Official Build) (64-bit)

@kuceb
Copy link
Contributor

kuceb commented Jan 11, 2019

@jadiaz, this is because you have target="_parent" in your <a> tag, which tells the parent frame of the window to navigate, not the current frame.

We should probably rewrite target="_parent" to target="_self" in the proxy layer in order to behave the same way as non-iframed app would

In the meantime, you should change your code to use target="_self" (this will not affect your site's behavior in any way), and is also the default target of an <a> tag. see the target section here https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a

@kuceb kuceb closed this as completed Jan 11, 2019
@kuceb kuceb reopened this Jan 11, 2019
@kuceb kuceb added pkg/https-proxy This is due to an issue in the packages/https-proxy directory priority: minor 🎗 topic: framebusting and removed priority: minor 🎗 labels Jan 11, 2019
@jadiaz
Copy link
Author

jadiaz commented Jan 12, 2019

Confirmed. Setting to target="_self" does fix the issue.

@jennifer-shehane jennifer-shehane changed the title clicking on element causes tests to stop running clicking on element with target="_parent" causes tests to stop running Feb 5, 2019
@goofiw
Copy link

goofiw commented Feb 7, 2019

This happens when target is set to "_top" as well.

Theres a solution in #1364

#1364

Is there any way to see better error handling rather than having the ui explode or the cli just hang?

@cypress-bot cypress-bot bot added stage: backlog and removed stage: ready for work The issue is reproducible and in scope labels Feb 7, 2019
@jennifer-shehane
Copy link
Member

@bkucera Brian mentioned that you are working on related work to this and this could be added to 3.1.6.

@andreirogobete
Copy link
Contributor

I looked at the "anchor target Property" documentation (https://www.w3schools.com/jsref/prop_anchor_target.asp)

It seems like there is a possible "framename" value that you can assign to the "target" property of anchors.

Example: Some Link URL

Looking at this, would it be possible to set the name of the iframe which Cypress injects to run tests to something like "cypress-runner-iframe". This way, you may update your anchor "target" attribute to point to that during your test runs.

Maybe this is not ideal, but it would probably a way better solution to set the "target" to "_parent" since you may have multiple iframe layers in your application.

@jennifer-shehane jennifer-shehane changed the title clicking on element with target="_parent" causes tests to stop running Rerouting with target="_parent" causes "Whoops, there is no test to run" Dec 13, 2019
@jennifer-shehane
Copy link
Member

Another clear reproducible example from #5938:

index.html

<!DOCTYPE html>
<html>
<head>
</head>
<body>
<form method="post" target="_parent">
  <input id="text_value" />
  <button type="submit" id="submit_form">Save</button>
</form>
</body>
</html>

spec.js

it('test', () => {
  cy.visit('index.html')
  cy.get('#text_value')
    .type('My Text')
  cy.get('#submit_form')
    .click()
})

@Santosh-src
Copy link

#5964 This issue resolved for me after modifying Configuration to "modifyObstructiveCode: true" from initial "modifyObstructiveCode: false". in Cypress.json

@testn
Copy link

testn commented Apr 20, 2020

so how do we want to fix this? modifyObstructiveCode does not seem to work for me.

@rodybothebynder
Copy link

rodybothebynder commented May 7, 2020

For me changing the attribute in the DOM worked:

cy.get('.approved-content .no-auto-submit').invoke('attr', 'target', '_self');

@BiswajitNanda
Copy link

BiswajitNanda commented Dec 4, 2020

@bkucera @jennifer-shehane In my application, the user accepts terms and conditions( a typical terms and conditions document where the the user scrolls down to the bottom and it asks the user to accept) and when the user clicks on the submit button, it throws "whoops no test found".

There are no iframes, the submit section is as follows.

< form method="post" action id="terms-form" >
< input type="submit" data-href="terms" name="accept" value="I accept" class="connect" > ==$0
< /form >

Any idea what is the cause of this error and how to address this.

@cypress-app-bot
Copy link
Collaborator

This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.

@cypress-app-bot cypress-app-bot added the stale no activity on this issue for a long period label May 18, 2023
@cypress-app-bot
Copy link
Collaborator

This issue has been closed due to inactivity.

@cypress-app-bot cypress-app-bot closed this as not planned Won't fix, can't repro, duplicate, stale Jun 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg/https-proxy This is due to an issue in the packages/https-proxy directory stage: ready for work The issue is reproducible and in scope stale no activity on this issue for a long period topic: framebusting topic: 😳 whoops there is no test to run Error msg: "Whoops there is no test to run" type: bug
Projects
None yet
Development

No branches or pull requests

10 participants