Cypress modal doesn't close - javascript

I've read 5-6 relevant Stackoverflow threads, none appear to pertain to this (famous last words).
Cypress 12.3.0 (was happening on v9 so I upgraded, but the issue persists).
Problem only occurs in automation.
Test conducted in headed mode (Cypress > Edge).
Click delete icon
Modal appears
Click delete button in modal
Expected result:
Action performed, modal closes.
Actual result:
Action performed, modal doesn't close.
Troubleshooting:
I added a command to close the modal using the modal's X button = Cypress can't find it.
If I don't add the above command, the succeeding test steps cannot click on elements because the modal that allegedly doesn't exist is covering them!
In Cypress > Edge, I can interact with and inspect the modal's elements.
This is crazy.
Code:
cy.contains('button', 'Delete Queue')
.click();
No iframes involved.
I'm enquiring internally to establish what JavaScript event or logic is closing the modal so I can trigger that. Or close the modal if it can be found with JavaScript...
Just wondered if you guys have any ideas?
Thanks

For whatever reason the app wouldn't close the modal after deleting the queue so I closed it myself using the correct CSS selector.

Maybe this can resolve your problem :
cy.contains('button', 'Delete Queue')
.click();
cy.get('[data-test-id="modal-close-button"]')
.click();
Let me know if it works.

Related

Blocked elements by default ? - Cypress

i wanted to ask if there are web elements blocked by default? If yes is it possible to not block them anymore?
Im running a cypress test and after clicking a save button there has to be a messagebox(similar to an alert).
This messagebox is not showing up after clicking the button.
Did anyone have similiar experiences?
Some infos :
Browser used : Edge
messagebox has the div tag
messagebox is nested inside of an iframe
I tried to run the test with the minium amount of code to verify if not some kind of comparision blocked me. But thats not the case.
I also tried a cy.wait for a longer time to see if it loads up.
I also tried a cy.reload but still nothing.
When i do it manually on Edge everything is working fine. The messagebox is showing up after clicking the save button but when cypress runs the test it just isnt showing up.
When i click on the button manually inside the cypress testrunner it´s also NOT showing up.

Popup window unrecognized by Selenium

Using Java, selenium and xpaths. I am verifying a Citrix project. Really all I have to do is login, show the favorites and apps buttons and that they are there. I get this window, which blocks everything:
And I can't do Selenium clicks until it is closed. Problem is, inspect does not show it, there is not a new windowhandle to locate it, and trying to find any xpaths does not work.
I can continue by using javascript clicks to click items blocked by this view, but it gets annoying and they may not accept it.
Before you suggest it, we are not allowed to use Robot. I looked for a Javascriptexecutor to just hit "ENTER" (since manually you can hit ENTER to download it) but couldn't find one. Uasing Actions(driver) does not work either because I think the window is not recognized.
There is a link "already installed" which I can click (with javascriptexecutor) and continue, but the popup window stays visible. Perhaps use Javascriptexecutor to open a link in a new window? But I tried some things which didn't work, although perhaps I did not have the right idea.
Any suggestions? BTW another solution that won't work is to do it manually the first time, because no matter how many times it runs and how many times the download button was clicked manually, the next time it comes up I get the window again.
Any ideas? (I scribbled out personal company info). Oh, and it is not an Alert. At least none recognized.

Can't find the javascript error

I have a button on my website but when I click, it doesn't respond. But the other button works. The location of the button where i got the error(which it doesn't respond to my click) is a bootstrap dialog. But the other bootstrap dialog works fine. May I have any suggestions or solutions ?
Following is the html code
<button type="button" class="btncanceldocument btn btn-warning" >
Cancel Document
</button>
And this is the javascript code
$(document).ready(function () {
$('.btncanceldocument').click(function () {
alert("Say hello");
});
});
Is there something wrong with it? if not i think the problem is on other javascript code. So how can i find the problem using my browser? or does my browser print some error? I have lots of javascript code on this file. I can't find the problem or error?
To answer your question, most browsers have a built in debugging tool. My personal favourite is Chrome.
If you right-click anywhere on your page then choose 'inspect' you will open it.
Here is a link that will help you - https://developers.google.com/web/tools/chrome-devtools/?hl=en
It's worth spending some time learning about that as it will save you in the long run.
When you open the debug you will be able to run JS code in the console, so you can manually fire your click using:
$('.btncanceldocument').click();
Then you will be able to make sure your code is working. If clicking with your mouse isn't working sometimes it could be as the button is actually behind a transparent element.
In the debug tool you are also able to select HTML elements so you can see if something is blocking the button. A quick tip for checking this is if you increase the CSS z-index property on the button to a large value e.g. '9999999999999' . This will bring the button 'above' the other content of the page.
Hopefully this helps,
Pete

See which functions of a chrome extension are being called

I'm trying to understand the code of a chrome extension I did not write. This extension is active the entire time and working in background. Now I'd like to see which functions are being called on the different actions I do on websites.
I got so far that I have to use the Debugging Console which I open with Ctrl+Shift+I, but how exactly do I have to do this?
I would try using the "Event Listener Breakpoints". You can get to it under the sources tab on the right hand side. Just expand desired section.
For example, if you want to track a click event on a button, expand Event Listener Breakpoints -> Expand Mouse -> Select 'click'. Upon clicking the button in the tool, it should stop in the code where the action is handled.
It is worth noting that the code will probably be minified, so reading it might not be trivial.

firebug keeps stopping execution of script

I must have clicked something accidently in Firebug, because on my site it keeps stopping execution w/ a little yellow arrow in the margin in the script console.
I cannot seem to stop this from happening, and nobody else on my team has this problem with firefox on the same page.
Is there a way to reset the debugger?
Screenshot: http://chovy.dyndns.org/test/bug.png
In the Script tab, clear all Breakpoints (which should be listed in a tab on the right).
From the browser toolbar on the Firebug button open the menu and select the last option "Empty the activation list".
Enter about:config in the URL bar, and make sure that extensions.firebug.breakOnErrors preference is set to false to not break on an error.
In the Script tab, click arrow pointing down. and deselect last two options.
I could not solve this problem. Even by removing breakpoints.json in the Firefox profile firebug folder it just re-appeared. I had to create a brand new profile and re-install all my plugins. That fixed the problem.
On mac, you can execute this to bring up profile manager:
/Applications/Firefox.app/Contents/MacOS/firefox-bin -p
http://support.mozilla.org/en-US/kb/profile-manager-create-and-remove-firefox-profiles
If you Deactivate Firebug (Tools->Webdeveloper->Firebug->Deactivate Firebug) the problem goes away for as long as you keep Firebug closed.
Removing and reinstalling Firebug solves it permanently.
You could just deactivate the script tab versus the entire firebug tool.
Bring up firebug, navigate to the script tab, click the down arrow unclick the "Enabled" option. Then just do the same thing again but enable it this time.
Had a similar issue, was pretty annoying but this solved it.

Categories

Resources