I would like to run the following Code on a Website:
document.getElementById("FileLeafRef_8553196d-ec8d-4564-9861-3dbe931050c8_$onetidIOFile").value = "test";
The Problem is that I have to choose the Frame "EditForm.aspx":
In the IE I can easily choose the Frame by manually clicking on it, but I would like to do it only in JavaScript, without a Manual select.
I tried it with a
parent.frame[x]
But I think this is the wrong path...
Related
I need some help. I need to download financial statements that are located in PDF files to my MAC using Python. I've tried this using Selenium but unfortunately haven't been able to make progress.
Following is the URL: financials.psx.com.pk
When I load this URL, the page looks like so:
you see the dropdown on the left above "Company Name...", I need to select a company name there. Once I do that, then I see a window like this:
Every link under reports, when clicked downloads a PDF. I require those PDFs. Appreciate any help. Thanks.
I have tried the following code; it selects the company name and shows me the next page for a second but somehow another refresh happens, which leads me back to the original page:
driver = webdriver.Chrome(executable_path="driver-path")
driver.get("https://financials.psx.com.pk/")
elem = driver.find_element_by_id("country")
drp = Select(elem)
drp.select_by_value("SHEL")
Actually, when I select using select_by_value, I can see the second window. I think the code is not stable. But, I am able to select a symbol from the dropdown and see the second page. Now, I need href's from the second page behind links such as 'Quarterly', 'Annual' etc.
For my daily work, I'm trying to create a Python Script which is able to fill in different forms, from different websites.
Here is the thing, for some kinds of website, I'm not able to catch the form elements which Selenium. E.g. in this website : https://econnect.bpcl.in/selfservice-ext/pub/login.html Where I inspect the page with Chrome, the input "User id" box has the id "principal", but Selenium is not able to get it. And when I display the html code of this page, the form looks like being included from another page or something.
I tried to getelementbyid, byname, bycssselector, etc. I also tried to wait for the page to be entirely loaded by using WebDriverWait(driver, 5), but it still do not work.
i also tryied driver.execute_async_script and driver.execute_script
Do you have any solutions or suggestions ?
PS : Even with javascript, I'm not able to get this element by id
Thanks
You can try to use x-path, I'm using a chrome extension: https://chrome.google.com/webstore/detail/xpath-finder/ihnknokegkbpmofmafnkoadfjkhlogph?hl=en
To locate the element you want to fill
And then you can use
driver.find_element_by_xpath("X-PATH").sendkeys("...")
If you don't want to download a chrome extension you can try to go the HTML script, but I doubt it would work because you said it wasn't working for you...
I have an invoice system made in PHP. There is a view with all customer's invoices. I'd like to make an option to print an invoice.
I know about window.print() and media="print" for CSS. But I was thinking, is it possible to just print an invoice by clicking a button next to it, but staying on the list page? It would just open a printing prompt with different content and do nothing to the current experience.
I thought of a workaround. On click, I could just replace contents of some element with invoice's data and make the styles hide everything else besides that container. That looks like a trick to me though. Is there any other solution to that problem? Perhaps something like download attribute for links:
Download Me
That could be something like:
<a href="invoice.php?id=3" print>Print Me</a>
Or perhaps an HTTP header? Please share some advices.
I would suggest to use JQuery PrintJS plugin below:
http://printjs.crabbly.com/
This will ultimately solve your problem.
I'm very new to javascript, so this is confusing me. All of the settings charm tutorials only show how to put the controls into the settings charm, but none of them say how to find the information gotten in them.
I tried to do one of these (like I do in the main program):
var muteToggle = document.GetElementById("Mute");
where "Mute" is the id in the separate html file.
muteToggle just ends up being null all of the time. I tried putting it after
WinJS.UI.ProcessAll().then(function completed() {...
but that didn't work either. Everything else is the same as in this page: http://msdn.microsoft.com/en-us/library/windows/apps/hh780611.aspx
Make sure you're doing it in the ready function of the js file that is referenced from your settings HTML. Try opening the JavaScript console or QuickWatch while broken at that line and also look at the DOM Explorer to see if you can find your toggle control. You should be able to access it though. Also, try element.getElementById instead of document.getElementById. Either should work actually, but as long as you're troubleshooting. Good luck.
Your problem is that you are trying to get a reference to the HTML element from the code running during the app activation. Although that piece of code may define the HTML to be loaded for a settings pane, it does Not actually load the HTML into the DOM. You just simply can't get the instance from that location.
What you need to do is have the settings flyout have its own js file that implements IPageControlMembers. In particular, you need to implement the ready method. This method is called once all the HTML and controls are loaded for the page, including your toggle. The link has an example of how to do this.
Also see:
WinJS.UI.Pages.define
Using single page navigation
So I have this js code for an image gallery:
(this.settings.update_window_hash) {
var thumb_link = this.images[this.current_index].thumb_link;
if (thumb_link.attr("id")) {
window.location.hash = "#image-"+ thumb_link.attr("id"); //#url
} else {
window.location.hash = "#image-"+ this.current_index;
};
};
So as you've probably assumed this appends $image-(int) to the url. So if I have a
gallery with multiple images if the thir image is selected the url will look like this:
mysite.com/gallery.html#image-3
All good. But I dont really like this to be appended to the end of the url. So is there
any problem if I remove this part of the script entirely? So regardless the number of
image currently selected the url will look like this:
mysite.com/gallery.html
I've tested it and it works okay. But I'm not very experienced with javascript and I want
to make sure I'm not making a mistake. So
IS IT OKAY IF I REMOVE THIS SCRIPT ENTIRELY? WILL IT CAUSE ANY PROBLEMS?
HUGE THANKS.
Hashes at the end of the URL are optional and not required so YES, you can remove that script if you want (I'm not sure what problem you're trying to solve by removing it). In general, you get more useful answers if you tell us what problem you're trying to solve rather than what solution you're trying to use.
Hashes are used when you want the URL of the page to direct the viewer to some subcontent on that page. If you remove them, your page will still work just fine, but the URL of the page will not reflect which image is displaying. So, if the viewer saves that URL and comes back to it or links to it or anything that keeps a reference to the URL, it will go to the generic version of the page, not the onethat shows a specific image. Whether that is OK is totally up to you and how your page works.
Just use:
location.replace(location.href + "#myhash");
The location.replace method overwrites the current step in browser history. For an example of this in action see http://prettydiff.com/slideshow/
The stuff after the octothorpe normally represents a "name" or "id" from the web page. You can have an anchor tag (<a name='thevalue'>) and the browser will interpret the text after the octothorpe (http://example.com#thevalue) by scrolling to the associated section on the page.
Unless the page has special JavaScript to behave differently. In your case, it depends upon the full functionality of the web page you're writing. If you have smoke tests/unit test/use case tests/other QE tests, you should execute those to ensure that your changes don't break anything.
See http://www.w3schools.com/html/html_links.asp for more description of the standard usage.