The selenium got the different html source from my local pc - selenium

I fetched http://book.flypeach.com/default.aspx?ao=B2CZHTW&ori=TPE&des=KIX&dep=2015-06-12-undefined-undefined&adt=1&chd=0&inf=0&langculture=zh-TW&bLFF=false by driver.current_url
However I got timeout error by this code
wait = Selenium::WebDriver::Wait.new(:timeout => 10) # seconds
wait.until { #driver.find_element(:css => "div.WrapperFlightDate") }
But I can see the css attributes div.WrapperFlightDate was truly exsiting in the page_source,
How could it happen ?

When I opened given link and trying to see given class in source code(ctrl + u),I didn't find given class.May be page was not loaded properly.
I refreshed page and right click on page -> View Page Source option then got this class in source code.Even I also ran this successfully in FF.
I also surprised why I didn't see correct source code first time.
You also try same,hope so you also get correct code now :).

Related

Cypress Uploading

describe ('Upload Test' , function(){
it('Upload Test' , function(){
cy.visit('https://document.online-convert.com/convert/csv-to-excel')
cy.get('#fileUploadButton').click()
const catalogue ='../integration/Example.csv';
cy.get('#file').attachFile(catalogue);
cy.get('#multifile-submit-button-main').click()
})
})
i tried to upload the csv file and click on convert it, At cypress test result it shows that the file have been uploaded but actually its not.
enter image description here
I hope you're using cypress-file-upload. Your file seems to be in the integration folder. I would suggest putting all the files required for Cypress tests inside cypress/fixtures folder and calling them as fixtures.
I would also higly suggest to use cypress-file-upload.
With it you can do it like that:
First, you get your input field for the file. Then you can use .attachFile to declare the source and give it a name
cy.get('.FileInput input[type=file]')
.attachFile({filePath: 'Example.csv', fileName});
There are a couple of events attached to the input that need to be fired after you attach the file.
The user will click the "Choose file" and the OS opens a file selection dialog. Since Cypress can't control that dialog, you are effective replacing that step with .attachFile(...).
As soon as the file is attached, the upload begins automatically and when complete, the file name appears in the file list element.
The element we need to attach to is <input id="fileUploadInput" type="file">.
If you inspect this element, and look at it's event listeners there's a change event and a custom event fileuploadsubmit that look useful
This is the code that works for me
const catalogue = "../fixtures/example.csv";
cy.get('#fileUploadInput')
.attachFile(catalogue)
// this just confirms the internal file property of the element
// i.e confirm the attachFile worked
// You can leave it out, it does not affect the process
cy.get('#fileUploadInput')
.its('0.files')
.its('0')
.its('name')
.should('eq', 'example.csv')
// Now trigger the change event
cy.get('#fileUploadInput')
.trigger('change', {force:true}) // force because the input is hidden
// And the fileuploadsubmit event
// Note that after change event, the input is detached from DOM
// so we need to re-query for the id
cy.get('#fileUploadInput')
.trigger('fileuploadsubmit', {force:true})
// Confirm the file is in the file list
// if it's a large file, allow enough time with a timeout option
cy.contains('span', 'example.csv', {timeout: 10000})
// Now start the conversion
cy.get('#multifile-submit-button-main').click()

Cannot refresh content in browser using http-server with Aurelia

I'm using Aurelia with http-server, as it is described in Aurelia getting started docs. I'm unable to see changes, because any browser seems to cache entire page at first load. When I use F5, ctrl+F5 or ctrl+r, page refreshes but nothing changes, none of my modifications are visible. Then I can use another browser and at first visit changes are visible, but any subsequent visit shows always the first one. It occurs in every browser I use (Chrome and Firefox, ever in private mode). I'm certain that it is not bug in Aurelia itself.
I tried to change port and use http-server with -c parameter. Nothing changed. Any ideas?
If you want to force your Aurelia app to be constantly refreshed after you modify it, you can have a look at the following thread:
https://github.com/aurelia/framework/issues/94
Aaike commented on 8 May 2015:
change your index.html to add the extension right before you import
the aurelia-bootstrapper
<script>
var systemLocate = System.locate;
System.locate = function(load) {
var System = this;
return Promise.resolve(systemLocate.call(this, load)).then(function(address) {
if(address.lastIndexOf("html.js") > -1) return address;
if(address.lastIndexOf("css.js") > -1) return address;
return address + System.cacheBust;
});
};
System.cacheBust = '?bust=' + Date.now();
System.import('aurelia-bootstrapper');
</script>
This is a caching issue that pops up sometimes with http-server. I don't know exactly what causes it but I believe the -c modifier changes the length of cache-control so I would set that as 0 or 1 instead of assigning a port that way.

Change ItemFileWriteStore URL, get data and refresh Grid

I have an EnhancedGrid with ItemFileWriteStore. After calling startup() on the grid, I hide the same by using following code:
dojo.style(grid.domNode, 'display', 'none');
And then on the click of a button, I change the URL of store for this grid and try to refresh the store and show the grid by using following code:
store.save();
store.close();
store.url='AjaxPopulate.json?os_type='+dijit.byId('osType').get('value');
store.save();
store.fetch({query:{id: '*'}});
dojo.style(grid.domNode, 'display', '');
grid.store.close();
grid.setStore(store);
The above code works fine with Firefox and Chrome but not on IE8 and IE9. I simply get "Object Error" message in IE Developer tools console.
Pls. help me identify any issues with the above code.
Howto reload store
If using the 'data' property to populate store initially (via constructor), you should set clearOnClose: true as well.
Use of .save() is only for a ItemFileWriteStore that has some settings changed (isDirty) and needs to propagate these to server. That said, you dont need .save on a closed store (allthough url has changed, no fetch has been run and definately no items has changed).
Try the following code, you'd only need the grid component to do it as calling .render() on the grid will get it to reload it's data.
// save if dirty, otherwise we cannot close a store unless its reset
grid.store.save();
// close store, this should clear data
grid.store.close();
// set new URL
grid.store.url = '??';
// rerun fetch XHR
// reload grid data with new items (no need to setStore as its same object reused)
grid.store.fetch({query:{id: '*'}, onComplete: function() {grid.render}});
Problem was that I had invalid JSON coming from server with one extra comma.
IE is very specific on these things.
Thanks everyone who viewed and tried to reply.

FileUploadDialogHandler()

I am trying to automate a web app which involves selecting an existing file using a fileuploaddialoghandler() method and entering the full path in the file name dropdown then Open click.
However, when I attempt this using this code
FileUploadDialogHandler fileupload = new FileUploadDialogHandler(#"C:\TIFFiles\Testtif.TIF");
//browser.WaitForComplete();
using (new UseDialogOnce(browser.DialogWatcher, fileupload))
{
newIee.Button(Find.ById("ctl00_WebPartManager1_FileUpload_FileBrowse")).ClickNoWait();
browser.AddDialogHandler(fileupload);
browser.WaitForComplete();
browser.RemoveDialogHandler(fileupload);
}
It does not work.
What else should I be doing?
Thanks much!
W
I just have one question about your code... What is newIee? I can't tell by looking at the code if newIee is attached to browser. Other than that, your FileUpdateDialogHandler should be fine.
If you can provide the code where you declare newIee, it might add me in determining if it's a factor causing your code not to work properly.

Possible dijit.Tree Cookie issue (SaveStateCookie)

So our app is set up like the standard left frame with the tree, right frame has the main content (loaded from clicking the tree).
Our web app inconsistently displays a blank page in the main frame in Firefox. By inconsistent I mean everyday for a few, rarely for others, never for most. Once we get this, going to any other page through our tree results in a blank page. We found that deleting the "aTreeSaveStateCookie" restores normal operation. "aTree" is the name of our Div. I found "SaveStateCookie" strings in dijit/Tree.js.
This also happens in IE, except I would get a browser error page which I can't recall right now. I would then delete the only cookie I could find for our app (not sure how to do the Firefox steps in IE)
Any ideas on why this would happen?
Thanks
Dojo 1.3 through http://ajax.googleapis.com/ajax/libs/dojo/1.3/dojo/dojo.xd.js
Firefox 3.1x
IE 8
Windows XP
In my case, I don't recall ever changing browser settings around Private Data.
Please check to see if the response code is 413 (413 = request entity too large), usually this happens when the cookie(s) used to store the tree(s) expansion state (aTreeSaveStateCookie) exceed(s) the maximum request size for your server
You could try increasing the maximum request size (follow instructions for your specific web app server) or at least display a meaningful error message like "please clear your browser cache" when the 413 error code is encountered
If the persist property is set to a truthy value, dijit.Tree is persisting its state to remember which nodes were expanded, and expand them after a page reload. If you need to persist the tree state in presence of a very large data structure, I recommend overriding Tree to use localStorage instead of dojo.cookie.
This is Dojo v. 1.9, but similar changes can be done to the non-AMD version 1.3
_saveExpandedNodes: function(){
if(this.persist && this.cookieName){
var ary = [];
for(var id in this._openedNodes){
ary.push(id);
}
// Was:
// cookie(this.cookieName, ary.join(","), {expires: 365});
localStorage.setItem(this.cookieName, ary.join(","));
}
},
And:
_initState: function(){
// summary:
// Load in which nodes should be opened automatically
this._openedNodes = {};
if(this.persist && this.cookieName){
// Was:
// var oreo = cookie(this.cookieName);
var oreo = localStorage.getItem(this.cookieName);
if(oreo){
array.forEach(oreo.split(','), function(item){
this._openedNodes[item] = true;
}, this);
}
}
},