i am working on a progress, but it always crashes when i use the HTML spy. the reason i found out is that the iframe is changing. Is there a way to make it dynamic, so it reads and gets the iframe. so that i can add it into a dataitem and add it into the dynamic spy.
1 time it runs : /HTML/BODY(1)/DIV(6)/DIV(1)/IFRAME(2)/HTML/BODY(1)/DIV(1)/DIV(3)/DIV(1)/DIV(1)/DIV(1)/DIV(1)/DIV(2)/DIV(1)/DIV(2)/DIV(1)/DIV(2)/DIV(1)/TABLE(1)/TBODY(1)/TR(1)/TD(1)
2 time:
/HTML/BODY(1)/DIV(6)/DIV(1)/IFRAME(5)/HTML/BODY(1)/DIV(1)/DIV(3)/DIV(1)/DIV(1)/DIV(1)/DIV(1)/DIV(2)/DIV(1)/DIV(2)/DIV(1)/DIV(2)/DIV(1)/TABLE(1)/TBODY(1)/TR(1)/TD(1)
3 time: /HTML/BODY(1)/DIV(6)/DIV(1)/IFRAME(3)/HTML/BODY(1)/DIV(1)/DIV(3)/DIV(1)/DIV(1)/DIV(1)/DIV(1)/DIV(2)/DIV(1)/DIV(2)/DIV(1)/DIV(2)/DIV(1)/TABLE(1)/TBODY(1)/TR(1)/TD(1)
Spy the iFrame if possible, capture the path in a variable,
use Dynamic path for all elements by prefixing it with the iFrame Path.
if this does not work let me know and I can give you another option.
Related
specifically, I would like to test that the logo appears on the home page of the app. I guess I am not sure what I should use to look for the image.
I tried
it('has a logo', function () {
cy.visit('http://localhost:3000')
cy.get('img').should('contains' , 'My-Logo.png')
})
instead of cy.get I also tried to just use
cy.contains('My-Logo.png')
but it also fails.
I wasn't sure what element I should use or if I should be using get, but it fails. When I look at the source code for the web page, the logo is hidden within the javascript (nodeJS, vueJS,and expressJS application) and I noticed the javascript seems to add a sequence of numbers and letters to the image when I go to the image page even though the image name in the assets folder does not have it on there. My-Logo.d63b7f9.png.
I figured out the solution on my own.
cy.get('form').find('img').should('have.attr', 'src').should('include','My-Logo')
I inspected the element and found the <img src... line was embedded within a <form>. I could do a cy.get('form') and pass, but could not do a cy.get('img') to pass. So then I chained them together and it passed. I am not sure why I cannot just simply add the second should statement, but it failed when I tried to just run:
cy.get('form').find('img').should('include','My-Logo')
I am not entirely sure why, but it needed the first "should" statement. I got around VUE adding the sequence of numbers and letters by just asking for the name of the file without the extension. I hope this maybe helps someone else as the documentation did not seem to cover this.
you can use only one should statement like:
cy.get('form').find('img').should('have.attr', 'src', 'My-Logo')
the third arg of should is the value to match with the element attribute.
I want to embed a HTML file inside of my electron app. I chose to use iframe, however - when I do this - it seems like I can no longer use node.js. Any attempt at using require("electron") will show that require is not defined. Any ideas?
Thanks in advance!
Stijn
if you don't mind a late answer, you should probably use a <webview>, as it gives you a more fine grained control on what you need.
If, however, you really need to use an <iframe>, you have two choices:
use parent.require (parent accesses the iframe parent, which should be your window)
on the load event, copy the parent window's require to the iframe one:
iframe.onload = function () {
const iframeWin = iframe.contentWindow
iframeWin.require = window.require
})
The only "downside" is that your included packages will be accessing the main window DOM instead of the iframe's one, which means that none of the iframe window global variables will exist and, more importantly, document will access the window DOM (querySelector and getElemementBy methods won't really work). Whether this is a problem for you depends on how you organise your code, so good luck there
I've this page and in my background page I'm blocking a url which defines stationName variable.
As explained in
Insert code into the page context using a content script I'm able to inject stationName variable( using first technique) but unfortunately it gets injected too late, after execution of all downloaded javascript code from website which don't find stationName variable.
How to define this variable before the javascript execution of page starts?
I've placed this file at resources/irctc containing stationName variable and in chrome.webRequest.onBeforeRequest.addListener I'm redirecting it :
return {redirectUrl: chrome.extension.getURL('resources/irctc/stationnames.js')
};
And it's working but I'm still looking for the right way.
Suppose I want the browser to load an image right on the first connection it makes to my website. How do I do that, considering that by default the image loads later on when it's actually called for?
Also, after the whole page finishes loading, suppose I want to load more objects (say images) that aren't required yet but are just for buffer. How do I do that? Help me people, I've been at it for quite a long time.
I'm somewhat successful with the first problem by adding a script tag while actually calling an image at the beginning of my index.php's html head part which goes like:
<script src="http://www.mysite.com/my/image/url.png"></script>
But this I realize is bad scripting.
As for "Why would you want to do that?", it's for educational purposes and also because when someone visits my site, I need to load and display certain things before other things get loaded.
For preloading you probably could start with
<body onLoad="Preload('image1.jpg', 'image.gif', 'image.png', ...)">
And preload is a JavaScript function which adds each of the array of images to DOM like
document.imageArray[i].src = args[i];
If I load a string containing HTML into a UIWebView, and that string contains objects (hyperlinks) that are relative to that string, i.e. , where there is some object with id "something," then the link works - click on it and the web view jumps to the referenced object.
What I want is to get navigation to a different file in my project, in other words as though the path to the different file were a URL.
I have found that if the href IS a URL, such as href="http://www.amazon.com", then the link works.
If I put the name of a file, OR the [NSBundle mainBundle] pathForResource: ] of that name, in the href, then the link does not work.
Is there some way I can generate the equivalent of a URL pointing to an HTML file that is in the project, so that an can link to that HTML file?
I found a solution at this link:
How to use Javascript to communicate with Objective-c code?
Essentially, the solution is to implement the UIWebViewDelegate protocol's shouldStartLoadWithRequest method, and "trap" a particular value of scheme. So my links, instead of saying something like:
<a href="http://someplace.location">
are like:
<a href="mylink://#filename.ext">
By catching attempts to load anything with scheme "mylink," I can use:
[[request URL] fragment]
within shouldStartLoadWithRequest, and get the filename.ext. I then release my previous UIWebView, load in the contents of the specified file, and make that the contents of a new UIWebView. The effect is that the links work with normal appearance, even though they are being implemented with my code. I return NO because I don't want the usual loading to take place. If the scheme is NOT mylink, I can return YES to allow normal operation.
Regrettably, I still have no way to jump TO a fragment within a web view. In linking to a real URL, you can say something like "www.foo.org#page50" and jump straight to wherever an object on the new page has an id of "page50." With my method, I can only go to the top of the page.
This is also not going to give me a "go-back" function unless I record the filenames and implement it myself.