I am building a plug-in for IE browser. The feature i am working on requires to read the urls from user's open tabs and save it in a database.
I do know how to read the URL from the current open tab, but if there are several open tabs I do not know the way to navigate through tabs so I could save the rest of the Urls.
Does anyone know any useful Api calls I could use that would allow to navigate through open tabs in IE browser?
Thank you.
Related
I created a program in c# with webbrowser control that opens a web site and the user will be automatically logged in. That works. However the user should also browse through different web site sections and that's where I get a problem. There is a button on one page "print preview" and what it does in "normal browser" (IE or Mozilla) it opens a new tab and shows the contents. In my program it opens Internet Explorer (it is the default browser) and shows me login page again. Can anyone explain how to open a new tab in my webbrowser control (or new window) and pass login data.
Thank you.
It can't be done the way you are trying to do it. There is no concept of tabs in the web browser control. You can verify this by loading up an html page that makes calls to window.open() in javascript. If that call is made it will just launch an instance of IE that navigates to that particular URL.
Your best bet is to have multiple web browser controls and pass data between them. Either that or use HttpWebRequest.
Although, depending on what you are trying to do you may want to automate IE instead.
I am trying to automate testing for a site that uses an iFrame(?) sort of punch-out which links to another website's catalogue to make purchases. The process is the user will login and be able to select a set of catalogues to connect to. Upon clicking a catalogue set they will be prompted w/ this security dialog:
and once they click 'Show all content' they are prompted w/ this:
This will take them to the actual catalogue site where they can place orders. Is there any way to interact w/ these prompts?
Try AutoIT, It can click on the screen using windows ids
https://www.autoitscript.com/site/autoit/
It'll create an exe and just call the exe whenever you like.
Selenium Webdriver is not able to interact with native browser popups. It does with JavaScript alerts and dialogs but that's not what you are trying to do.
The common solution to working with dialogs (file uploads, login dialogs) is to circumvent them by sending the file data or login info to the HTTP request.
See this question or this question for examples of these two scenarios. In your case you can't do that.
You could use another product (something other than Selenium) or change the IE configuration or the setup/environment of the tests so you are not prompted by these security alerts.
For example, for your first alert: "Only secure content is displayed", you can disable it by going in the IE options, security, Custom Level and then disabling Display non secure items.
I'm creating a web page with a download option
when the user clicks the the download option he gets three options
Open
Save
Save As
I just want the user to see
Open
I'm using ASP.NET 4
Thank You
p.s. i tried google but no good
You can't do this, this would be a security risk. I think the next best thing is to have the user register an application to a uri scheme, this is something that needs to be configured on the client pc trough the registry. ( for windows )
Off course, this means your application needs to support this as well. You can see how that works here:
http://msdn.microsoft.com/en-us/library/aa767914(v=vs.85).aspx
The best thing is to have this register when the application installs trough the installer, otherwise you can provide an executable to modify the registry, or do it manually on every client, or have the user download an executable from the site, which ever is feasible.
If you are developing the client application, you could go the other way and have it poll the webserver, but that is off course a more evolved solution.
Depending on the file type you are serving, you may be able to add the following header to the response message:
content-disposition: inline
Code:
Response.AddHeader("content-disposition", "inline")
This will tell the browser to open the file immediately instead of displaying the dialogue box. But it will only work if the browser supports the file type.
Save, Save As, Open are your browser's options. Check in different browsers and you will see different options. Hell, I could make a browser with "Hit", "Hit Me", "Hit Me Again" and "Take a Look" options. You cannot control them from your asp.net code.
The best you can do from your code is to instruct your browser to display the downloaded content inline or as an attachment using:
Response.AddHeader("content-disposition", "attachment;filename=somefile.pdf")
or
Response.AddHeader("content-disposition", "inline")
The first option will trigger your browser's download options (in your case will show Save, Save As and Open buttons). In my case Chrome will automatically save the file without asking me anything.
The second option will directly open the file but ONLY if the browser will correctly identify the content-type of the downloaded content and if it CAN display it.
For example, for a PDF file you need to set:
Response.ContentType = "application/pdf";
and you need to have Acrobat Reader if you are using older browsers or you need to use a newer browser that already has a PDF plugin installed (IE7+, Chrome, etc...)
I hope this helps.
I want to get the URL from all open tabs. I have searched on Google but could not find any luck. I want to read and log the URL from all open tab from Chrome And IE.
I am using C# windows form application.
Thanks in Advance..
Umang
I understand what you need to do but I would be surprised if IE and Chrome would expose the tabs and the urls in a simple and similar way to external applications, I think the way to go is to build a Chrome extension and an IE plugin or Addin to get those information while running within the browser scope, then you can send this info to an external application or to a web service etc... you will find a way to get the info out once you have got this url list inside your own code running with the browser.
see here for some starting point / ideas
Chrome extensions:
http://code.google.com/chrome/extensions/index.html
IE development:
http://msdn.microsoft.com/en-us/library/bb250436(VS.85).aspx
I am accessing the SHDocVw.InternetExplorer from the SHDocVw.ShellWindowsClass(). I can see the page that the browser instance is currently on (the LocationURL property), but what I really need is the last get request that was done for the browser. My specific need is that my application was just launched to handle a file that was downloaded to the user's system via a link on the current web page. I need to know the URL of that file. LocationURL gives me the URL of the page that the link is on, but I need the URL of the file/link.
EDIT: The web application I've been trying to interface with is SharePoint. I wasn't able to find a way to extract the URL of the last clicked link (file downloaded) from Internet Explorer, so now I'm hoping to find a way to get that information from either SharePoint itself, or piggyback on the Name ActiveX control that SharePoint uses to manage the download of MS Office documents. Any SharePoint/Name ActiveX experts out there?
Since you can't get the url from Internet Explorer's history using IUrlHistoryStg::EnumUrls http://msdn.microsoft.com/en-us/library/aa767720%28VS.85%29.aspx
try making sure the file association is setup one the box and that your app can take a file path from the command line to start up.
I added these keys to my registry
[HKEY_CLASSES_ROOT\.sdr]
#="sdrfile"
[HKEY_CLASSES_ROOT\sdrfile\shell\open\command]
#="\"D:\\Shenanigans\\MyGreatApp.exe\" \"%1\""
on a Win7 box and IE/Sharepoint figured it out. If you poke around HKCR you'll see that it can get more complicated to setup file associations, but see if this works.
Sink DWebbrowserEvents2::OnBeforeNavigate2.