Prevent new tab when opening URL from C# - c#

I have a C# application that opens a URL in the default browser when the user double clicks on the System Tray icon provided by the app.
How can I prevent a new tab opening when the user double clicks again, after already opening the browser at that URL?
Is it possible to set the focus to that already opened tab instead?
I am using Process.Start(url); to open the browser

Related

Need to enter the value of username in a webpage opened through a function in wpf

On button click in wpf view, the webpage should open in the background and there is a field for username in webpage that should be auto-filled.
The method to open webpage I am using is :
Process.Start("https://example.com/");
Using this it opens the webpage in the foreground of the wpf application.
Used this.Topmost= true; for the MainWindow of wpf applications, this just keeps the main wpf application in the top.
I want 2 things,
1.) the other webpage that I am opening through the wpf application, that should be opened in a minimized mode.
2.) I want to enter the username automatically in the webpage opened through wpf application's button click.
Set the minimized window style for the process with the ProcessStartInfo by following the example on the documentation page. Also for the web page to display the user name you need to provide that as a query string parameter and then handle that in the page itself.

Handle drop down on web page dialog selenium C#

I am working on a automation of a website using selenium and C# , but i stuck in a situation where on a button click a new webpage dialog open and on that web page dialog we have to select some value and click on save button. Problem is i am unable to switch to that webpage dialog and even f12 window not working on that webpage dialog this website is only working on IE so no other option . Please help me. Here is post screenshot of webpage dialog and HTML code of Button which open that dialog box.
I have got this problem, where the title of page is Webpage dialog same as you. In this window you can not inspect the element. Solution to this is go to
Internet Explorer-->
Internet Options -->
Security tab -->
Custom Level -->
Disable the option : Allow Websites to open windows without address or status bar
Now, You can inspect element by F12 in IE. now, simply write all the selenium commands, you can also use JavaScriptExecutor for that, If you dialog box calls JavaScript.

Facebook Desktop Auth pop up Browser

I'm writing a desktop app in C# that has Facebook integration and I'm trying to figure out how to do authentication/login. I have thought of two different approaches:
1. Popup default browser
The user probably is logged into Facebook on their default browser.
Code: System.Diagnostics.Process.Start("http://www.facebook.com/...");
Issues/Questions: How do I control the window location and size (e.g. not show address bar when it starts)? Can I destroy the process after login is complete or even close the window (won't most browsers prompt for window closing if done from javascript?)?
2. Popup specific browser
If I lookup the default browser, I can pass command-line flags to the browser. "..\chrome.exe" --app=http://www.facebook.com/...
Questions: How do I set the window size/location? How do I close the process after login-complete (assuming I know when the login is complete)?
Is there a better way to do this?
very usefull resource in this situation is http://facebooksdk.net/.
Earlier, there was a sample project for desktop application on facebooksdk.net, but it was removed. You can see it here https://github.com/MarkAureliy/facebook-winforms-sample-master
This project is straight for your needs

selenium fails to open intended new window

I am trying to automate web based application (asp.net) through selenium web driver.
Web application has login page and once I log in, I need to click on a button that opens a new window and then perform operations on this new window. So far, my code is able to login and click the button. Two problems here:
instead of opening desired window on click, it opens the login page
this login page is opened in the same window, not new one
I have used below statement to switch to new window:
webDriver.SwitchTo().Window("newwindowname");
Have you tried to use the window handle?
Get the window handles
ReadOnlyCollection<string> handles = webDriver.getWindowHandles();
String myWindowHandle = handles.LastOrDefault();
And use the last one in the swtichTo statement
webDriver.switchTo().window(myWindowHandle );

webBrowser popup window loses session

I am using WebBrowser control of .NET to login into a website. When i click on a button that popups a new window the popup window asks me to login again. However i am not asked to login again if i open the webpage in internet explorer. Is there any way to make the WebBrowser control store session so that i do not have to login again on the popup window.
To maintain the session state you can use the NewWindow2 event to open the new page in another form in the application; the event is triggered by the WebBrowser control.
Make sure that before clicking the button you already made Login.
In both cases, I think the solution which I am going to give will work for you.
For this purpose, I think you place login fields in panel and on page_load check either session empty or not if not then visible it false if yes then visible it true.

Categories

Resources