Fill form values on external website using Selenium? - c#

I have a ASP.Net application .When user clicks a link, his username and password for a third party website should auto-populate to that website.
I have seen Selenium web drivers can do this, but only on the local machine(server).
Is it possible to automate this on client browsers?

I do not think you can do this at client side that will be security issue then. Any way once you open the third party website on a click from your website either that new website loads independently or loads inside a iFrame inside your application depending upon your inmplementation in both cases you can not access anything in the site using the Javascript or something else. And Selenium is not at all possible as it is Java you can not run it in a clients machine.

Related

How to communicate with Google Chrome using C# or Python

I'm developing a software on C# which has to get info from a website which the user opens in chrome, the user has to input some data and then the website returns a list of different items.
What I want is a way to be able to access to the source code of the page in order to get the info, I cant open the web myself as it doesnt show anything because I didnt input any data, so I need to get it directly from chrome.
How can I achieve this ? A chrome extension ? Or can I access to chrome directly from my software ?
Off the top of my head, I don't know any application that gets data directly from an open instance of Chrome. You'd have to write your own Chrome extension.
Alternatively, you can open the web browser from your application initially.
You can look into these libraries for doing so:
Watin (My personal favourite)
Selenium
Awesomium (You'd have to roll out your own UI, it's invisible)
Cef
Essential Objects Web Browser
EDIT: I didn't think about using QA tools as the actual browser hook as #TheAnathema mentions. That would probably work for your needs.
You're going to need to create it as Chrome extension if you must be dependent on the user actually going to a specific web site (i.e. not being able to do the requests yourself with either Selenium or standard web requests in Python).
The reason why a Chrome extension would be required is because think of how bad it could be for any software to easily read the pages you browse. Banking, medical, email, etc. could all be accessed anonymously from any process if Google allowed any outside process to tap into the web page.
Even Chrome extensions have to ask for permission to be able to do what they want, but at least it is software the user knowingly installed and agreed to the permissions.
A quick search yielded this example of modifying a page's HTML with a Chrome extension: https://blog.lateral.io/2016/04/create-chrome-extension-modify-websites-html-css/
It sounds like you want to do web scraping. Here's a good tutorial to get you started: HTML Scraping.
And this answer has a good example of how to scrape data from a website where you need to submit a form to get access to the data.

Redirect a page to a different web browser

I have a ASP.Net page for our company and we are running a parallel testing to the new web site. Now, the I attached a clickable image on the old website which redirects to the new web site.
My problem is the old website can be browsed in any web browser while the new web site must only be opened using a specific web browser (due to the developers of the new web site said that it only works properly on google chrome).
All I need is when when they browse the old web site using whatever browser they have, and then click the image, it will open the new website using google chrome.
These web sites are published on the company's windows server, and all clients that connects to it has google chrome installed with them.
If there is something like:
System.Diagnostics.Process.Start("chrome.exe", <url>);
that will be executed on the client side (not on the server side), kindly advise.
This is not possible unless you have some client software that can receive a call from the website to launch Chrome. My answer can be backed by this question about IE redirection to other browser. The accepted answer is absolutely correct.
The security risk would be too great and besides windows doesn't support that kind of linking. You could write a "client" program that runs in the background waiting for a call from your website. Then the client program could launch Chrome.
Hope this helps you!
Is it your problem ? : you want to open your link via Google chrome .
if yes , you cant do it !
because ASP.net , PHP and etc .. a server side language and cant do it ! , its not possible without have any application on clients .

Invoke javascript methods on a page

Is there a way using either C# or a scripting language, such as Python, to load up a website in the user's default webbrowser and continue to interact it via code (e.g. invoke existing Javascript methods)? When using WinForms, you can host a Webbrowser control and invoke scripts from there, but only IE is supported. Is there a way of doing the same thing in the user's default browser (not necessarily using WinForms)?
Update: The website is stored on the user's machine, not served from a third party server. It is a help page which works dynamically with my C# program. When the user interacts with my C# program, I want to be able to execute the Javascript methods on the website.
You might want to look into Selenium. It can automate interaction with FireFox, IE, Chrome (with chromedriver) and Opera. It may not be suitable for your purposes due to the fact that it uses a fresh, stripped down profile, rather than the user's normal browser profile.
If you look at the HTTP request header you can determine the user-agent making the request. Based upon that information you can write logic from the server side as to respond with a unique page per detected user-agent string. Then you add any unique JavaScript you want as a static string to be executed by the user-agent application.

Redirecting to device settings

Say I have a mobile optimized website which runs with a lot of javascript on it to create awesome effects, and a user enters the website via a mobile browser which doesn't have javascript activated.
Is it then possible to (through a button click) redirect that user to his/hers browser settings?
You need to have JavaScript activated in order to browse this site properly.
Click here to change your settings
In principle, you can create an intent: URL that references an ACTION_SETTINGS Intent, though I have not tried this. Off the top of my head, the simplest way to construct that URL is to generate a scrap Android project and call:
Log.d("Something", new Intent(android.provider.Settings.ACTION_SETTINGS).toUri(Intent.URI_INTENT_SCHEME));
then check LogCat for the URL that you would put in the Web site. Of course, this URL will only work on Android devices.
I only know Windows Mobile (and there, only up to v6.1), but I would guess your clients would have to have some app of yours prior installed to access features of the device itself.
If websites could access a device's features, it would be viewed as a virus.

C# - How to control chrome browser

I wanted to make an application wherein you specify the name of the websites, your username and password and that application automatically logs in to all your accounts in the specified websites. I have done this using windows form application, using a web browser. But i wanted my application to open all these websites in chrome and log it in there. Plz Help
I'd check out the chrome API failing that
Look into getting a handle to the window through window API calls
But why not just a chrome extension?!? Miles simpler
Have a look at Selenium WebDriver
Doing a quick Google search for "chrome C# api" turned up a number of results I think you may find relevant.
I thought the following were particularly promising, if you're willing to accept a few concessions:
Automating Chrome Browser from C#
ChromeDevTools; a C# Library to interact with Chrome's Developer Tools
Chrome Debugging API

Categories

Resources