<a id="ctl00_MainContent_UndoButton" class="a-button a-button--cancel
dd-data-link"
href="javascript:__doPostBack('ctl00$MainContent$UndoButton','')">
Undo </a>
When i click the above button this open a new dynamic url popup which then injects the below script to open the page.
//<![CDATA[
ToggleTempChanged();TogglePermaChanged()
;window.open('**/products/Car/EndTempAdjustment.aspxenc
=Y/qlHvbv+Gt2rmvC4GL1GzEO87O1bd8H91aPhk96iKLRMC+yw
MY3gWzR7jpKnJVPaIz+srgg
NtdnpsEudpo4lEa7ccLMPe2PXXQlxREtp8nsWkPq
7qKCBnVCt7n0m7f953bwfRYXrngveDlNLAqC
wjpPP6eIp6Sz+oEtMBkjUEHJd4jztk2IEJcsHskdXH6H**');
var Page_ValidationActive = false;
if (typeof(ValidatorOnLoad) == "function") {
ValidatorOnLoad();
}
function ValidatorOnSubmit() {
if (Page_ValidationActive) {
return ValidatorCommonOnSubmit();
}
else {
return true;
}
}
document.getElementById('ctl00_RequiredFieldValidator1').dispose =
function() {
Array.remove(Page_Validators,
document.getElementById('ctl00_RequiredFieldValidator1'));
}
document.getElementById('ctl00_RegularExpressionValidator1').dispose =
function() {
Array.remove(Page_Validators,
document.getElementById('ctl00_RegularExpressionValidator1'));
}
//]]>
I have tried all methods to try and stub, remove attributes etc for the new window to enable me to carry out tests on this page with no success and checked other answers regarding dynamic url opening new windows. Would any one know how to extract just the dynamic URL from the code that is injected above. My plan is then to cy.visit to the extracted dynamic URL.
Assuming the CDATA
is coming to the page via and API call, you can find the URL of that call by looking in browser Developer Tools/Network tab.
The add an intercept to stub the call (so that window.open()
portion is removed) something like
cy.intercpet(url-dynamic-code, '//<![CDATA[//]]>`).as('intercept-undo')
cy.contains('Undo').click()
cy.wait('@intercept-undo') // confirms click happened
Then you could cy.visit('**/products/Car/EndTempAdjustment.aspxenc =Y/qlHv...')
to test that popup, but maybe that's not realistic since looks like popup needs to interact with main window.