Vist to https://www.binance.com/en.
Click on view more markets link.
The website is loading properly but when I am clicking on "View more markets" link. it is giving
the below error:
Blocked a frame with origin "https://www.binance.com" from accessing a cross-origin frame.
Before the page load, you were bound to the origin policy:
https://binance.com
A cross origin error happens when your application navigates to a new superdomain which does not match the origin policy above.
This typically happens in one of three ways:
1. You clicked an that routed you outside of your application
2. You submitted a form and your server redirected you outside of your application
3. You used a javascript redirect to a page outside of your application
Cypress does not allow you to change superdomains within a single test.
You may need to restructure some of your test code to avoid this problem.
Alternatively you can also disable Chrome Web Security which will turn off this restriction by setting { chromeWebSecurity: false } in 'cypress.json'.https://on.cypress.io/cross-origin-violation"
The code is below:
describe('My firs Test',()=> {
it('load page',()=>{
cy.visit("https://www.binance.com/en")
cy.xpath("//a[text()='View more markets']").click();
cy.wait(50000);
})
})
Did you try in your cypress.json file turning off chromeWebSecurity?
{
"projectId": "online-realestate",
"viewportWidth": 1200,
"viewportHeight": 1000,
"video": false,
"chromeWebSecurity": false
}
Related
I'm trying to login to our site which uses Auth0 and Google Sign in but I'm having issues with cy.origin it's behaving different in each browser, none of which is letting me log in. This is my test:
import { loginPage } from '../../page-objects/login-page'
describe('Login Tests', () => {
beforeEach(() => {
loginPage.visit()
})
it('GoogleLogin', () => {
// Click google sign in button - On My Base URL
cy.get("a[data-testid='googleSignInButton']").click()
// I'm now on an Auth0 Page where I click the Google Sign In Button
cy.get("a[class='auth0-lock-social-button auth0-lock-social-big-button']").click()
// Now I am on the accounts.google.com domain
cy.origin('https://accounts.google.com', () => {
// enter email on accounts.google.com
cy.get("input[type='email']").type('myemail#gmail.com')
// click next button seen on accounts.google.com page
cy.get(
"button[class='VfPpkd-LgbsSe VfPpkd-LgbsSe-OWXEXe-k8QpJ VfPpkd-LgbsSe-OWXEXe-dgl2Hf nCP5yc AjY5Oe DuMIQc LQeN7 qIypjc TrZEUc lw1w4b']",
).click()
})
})
})
The issues I'm seeing are:
In Chrome once I get to accounts.google.com the test times out with "Timed out after waiting 60000ms for your remote page to load on origin(s)"
In Firefox the test times out with the same error as on Chrome but on the Auth0 page instead of accounts.goole.com
In Electron when I click the Google Sign in button on Auth0 I'm taken to accounts.google.com but a message is displayed "403. That’s an error. We're sorry, but you do not have access to this page. That’s all we know."
In Edge I can get to accounts.google.com and enter "myemail#gmail.com" and click the next button but then I see a message "This browser or app may not be secure.
Try using a different browser. If you’re already using a supported browser, you can try again to sign in." with a Try again button.
Four browsers are all reacting differently and not one is letting me actually login, can anyone see what I've done wrong?
I've been running into a problem with Cypress (currently v8.3.1 but this has been a constant for years) where my test detects a cross origin error on page load, but I am 99% certain that shouldn't apply.
The test logs into a web application and attempts to access a project.
cy.visit(webapp) //login page
cy.login(userCreds) //enter user cred and access main page
cy.get(projectAcccessButton).click() //access project from main
As the project page loads, Cypress throws the cross origin error below. I've been using the "chromeWebSecurity": false workaround, but it does not apply to Firefox. Firefox test coverage is on the "2022 To Do" list, so I am turning to Stack for answers - I hope.
What I want to do: Access the project page without issue.
What has been happening: cross origin error on page load
Permission denied to access property "document" on cross-origin object
I mentioned that the cross origin error likely shouldn't apply because when I modify the test to access the project page via cy.visit(), Cypress does not throw an error.
cy.visit(webapp) //login page
cy.login(userCreds) //enter user cred and access main page
cy.visit(projectPage) //access project via url
This leads me to believe something is happening on the button click that is somehow triggering the cross origin error. Is it possible that the button attribute onclick="window.location.href='/projectManager/123456789'" is somehow being interpreted as leaving the main origin?
If this error is related to the window.location.href, how can I resolve this so Cypress doesn't detect an error when running in Firefox?
Full Error Message:
I am facing the cache issue whenever I do a new deployment, changes are not reflecting automatically. Always I have to go to the browser setting and clear the cache.
Is there a way to handle this issue automatically whenever I do the new deployment.
requirejs.config({
// Path mappings for the logical module names
paths: {
'knockout': 'libs/knockout/knockout-3.4.0',
'jquery': 'libs/jquery/jquery-3.1.1.min',
'jqueryui-amd': 'libs/jquery/jqueryui-amd-1.12.0',
'promise': 'libs/es6-promise/es6-promise.min',
'ojs': 'libs/oj/v3.2.0/min',
'ojL10n': 'libs/oj/v3.2.0/ojL10n',
'ojtranslations': 'libs/oj/v3.2.0/resources',
'signals': 'libs/js-signals/signals.min',
'text': 'libs/require/text',
'hammerjs': 'libs/hammer/hammer-2.0.8.min',
'moment': 'libs/moment/moment.min',
'ojdnd': 'libs/dnd-polyfill/dnd-polyfill-1.0.0.min',
'customElements': 'libs/webcomponents/CustomElements'
},
waitSeconds: 0,
// urlArgs will be appended at end of .js files
urlArgs: "v=1.33",
// Shim configurations for modules that do not expose AMD
shim: {
'jquery': {
exports: ['jQuery', '$']
}
},
config: {
ojL10n: {
merge: {
//'ojtranslations/nls/ojtranslations': 'resources/nls/menu'
}
}
}
});
You can update version (by changing urlArgs parameter in configuration) every time you deploy new code, thus every time new JavaScript file will be downloaded.
This can always be a problem during development. There are a couple of solutions.
1) Build into your app URL, a version string. Every time you publish a new version, change that number and the browser will pull new files
2) Set the cache control values on your server so that it doesn't cache anything from your app directory
3) Just do what you're doing with clearing browser cache. There are utilities that add a button on the browser bar to make it easier to get at.
I personally use the node http-server library to run my dev work and I use it's cache control arguments to make sure nothing is being cached.
http-server -c-1 -o
The above turns off caching and launches the browser from the current location (loading index.html if present)
With Chrome: if you open the Developer Tools (F12), on the Network tab you can check the Disable cache checkbox, which turns off caching, while the DevTools is open.
With Firefox: if you open the Developer Tools (F12), click the cogwheel icon ("Toolbox Options"), then in the "Advanced Settings" section, check the Disable Cache (when toolbox is open) checkbox.
Now there will be no caching in the browser. Might slow down stuff seriously...
After running a load test, in the results data, it shows that cached requests accumulate throughout the duration of the test, increasing over time.
In my web test, each URL has the Cache Control setting turned off, which is supposed to mean don't cache.
Furthermore, in my load test scenario settings, I have the "Percentage of New Users" setting set to 100, which means that each user should be treated as a new user, and not use caching.
With these settings, why are the test results still showing the increasing amount of cached requests throughout the load test?
I attached an image of the load test results graph of cached requests for clarification.
As you know, there is a property named “Cache Control” on each request.
When the Cache Control property on a request in the Web test is false, the request is always issued.
When the Cache Control property is true, the VSTS load test runtime code attempts to emulate the Browser caching behavior.
However, the Cache Control property is automatically set to true for all dependent requests (images, style sheets, javascripts, ...).
In a load test, the browser caching behavior is simulated separately for each user running in the load test. But event if “Percentage of New Users” is set to 100, the cache will be used during the virtual user session. If your web test contains many pages, the cache will be used.
Since VSTS 2008, you can now write a WebTestPlugin that disables caching of all dependent requests.
Note : When running a Web test by itself, the Cache Control property is automatically set to false for all dependent requests so they are always fetched : this allow you to view the html page in the browser.
Thanks to this blog I created the following class.
using System.ComponentModel;
using Microsoft.VisualStudio.TestTools.WebTesting;
namespace QuranX.Web.LoadTest.WebTestPlugins
{
[DisplayName("Enable browser caching")]
public class EnableBrowserCachingPlugin : WebTestPlugin
{
[DisplayName("Allow caching")]
[Description("If True then server responses will be cached")]
public bool AllowCaching { get; set; } = true;
public override void PostRequest(object sender, PostRequestEventArgs e)
{
foreach (WebTestRequest dependentRequest in e.Request.DependentRequests)
{
dependentRequest.Cache = AllowCaching;
}
}
}
}
The instructions then show how to install the plugin.
Build the app
Open the WebTest file
In the icons click "Add Web Test Plugin"
Set the "Enable browser caching" property to false
Couple questions about the implementation of the XHR request:
I am trying to make a form in popup.html that allows for the filling of a box with text (in popup.html) and submits that to a remote website using get and replaces the contents of the box with the return of the php (json).
Heres the code so far:
Any idea why when I click submit nothing happens?
Also the manifest permissions:
"permissions": [
"https://*/",
"https://*/*"
]
}
forms don't need permissions at all to do a cross domain post (in theory). That being said, the popup.html never reloads in a browser action (or page action) when a form is submitted.
An easy thing to do is to capture onsubmit on the form and simply do an XMLHttpRequest attaching the form as per the Mozilla MDC site.
Which in summary is (copied from mozilla):
var formElement = document.getElementById("myFormElement");
var xhr = new XMLHttpRequest();
xhr.open("POST", "submitform.php");
xhr.send(new FormData(formElement));