selenium fails to open intended new window - c#

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 );

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.

Embed Internet Explorer browser into Winforms using C#

I'm trying to open a IP specified webpage using IE (Why IE? Because not every Windows have Chrome or Firefox installed) and present it in a simple Winforms window.
The up-mentioned webpage is a BI (Business Intelligence) webpage that will update itself dynamically, and I want the user to sit and look at it while the page is updated with a new statistics.
Flow of events:
User will enter the specific IP address and click "Get the Web-page".
New Winform window will pop-up with the specific webpage inside.
Also, it will be great if there an option to hide IE navigation panel, because I don't want to give the option of browsing in this window.
I tried to do this using CefSharp, but I didn't get to anywhere. Every example that I saw was written in asp.
Here is was I did so far, and this is not working:
namespace BingoDesktopWindow
{
public partial class BingoWin : Form
{
public BingoWin()
{
InitializeComponent();
CefSettings settings = new CefSettings();
CefSharp.Cef.Initialize(settings);
ChromiumWebBrowser browser = new ChromiumWebBrowser("http://12.345.67.89/bingo/Default.html");
this.browserPanel.Container.Add(browser);
}
}
Thank you!
}
Why do not you use Winforms WebBrowser control. WinForms WebBrowserControl. You can manipulate it more than IE. Web browser control is itself derived from IE so, it has all its functionalities.

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.

Prevent new tab when opening URL from 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

Redirect open link event to extendedwebbrowser tab

I've got a webbrowser in a c# form and when the user click on a link the page opens in the ie10 browser.
All I want is to intercept this event and open the new page in another webbrowser (extendendwebbrowser really).
The fact is that i don't want to know what the user click in the page, but i'd like to intercept all the requests "open new page" from my webbrowser and redirect them to my extendedwebbrowserform and create a new tab with that link.
Thanks for help.
There are at least 2 ways to do that:
Extend the WebBrowser control to intercept the NewWindow2 event, then cancel original request and use that url to open it in a new window. Similar code can be found here or in code project Extended .NET 2.0 WebBrowser Control.
Implement INewWindowManager, and use EvaluateNewWindow to do the same.

Categories

Resources