Create a Chrome instance in WatiN - c#

I have been using WatiN with IE with great success, however am now wanting to move onto Chrome. It seems to me that if I can just create an instance of a Chrome browser it should be a similar process, but creating an instance of Chrome is proving to be a tricky task.
I am currently looking at:
WatiN.Core.Native.Chrome.ChromeBrowser
Am I on the right track? Or am I missing assemblies for a WatiN.Core.Chrome?
EDIT:
I have now investigated Selenium and am using it with some success for Chrome, Firefox and IE. For those requiring multiple browser support I would suggest Selenium over WatiN, at least till they have finalised their Firefox and Chrome implementations. Both are very handy for UI testing in general though!

Official website states that only supported browsers are IE 6-9 and FF 2-3. Chrome browser is only in experimental mode and isn't yet supported. There are couple of so posts stating that there was no success using chrome in Watin.

Related

Selenium with .NET Core does not show browser in release mode and ignore options

This bounty has ended. Answers to this question are eligible for a +50 reputation bounty. Bounty grace period ends in 3 hours.
Onur Topal wants to draw more attention to this question:
for some reason, selenium does not show the browser but looks like working fine. I can hear the audio it is playing and can retrieve HTML elements from driver and execute scripts.
I am using the below code to open a selenium driver with Chrome.
The first problem is --allow-file-access-from-files flag is not working at all either with debug mode or release mode.
Also, the main problem is when I publish my code with release mode and deploy another machine (Win 10 Pro) the app does not show the browser.
Edit: I think this is not clear selenium working fine but is hidden in some cases we need to display it for user input.
I also have an issue to play audio files automatically and the solutions I found on the internet are not working as well. Throwing JS error saying no click detected.
Is there a way to open a browser with full control? another browser for example firefox etc.
public static IWebDriver GetHeadless()
{
ChromeOptions cOptions = new ChromeOptions();
cOptions.AddArgument("user-agent=SeleniumTests");
cOptions.AddArgument("--allow-file-access-from-files");
//cOptions.AddArgument("--headless");
return new ChromeDriver(cOptions);
}
Thanks

Multiple selenium webdriver instances using Internet Explorer 11 interfere with eachother

I have the following situation, I have two test cases running in parallel that each open a selenium webdriver instance for Internet Explorer 11 and both navigate to the same login page and both try to login with a different username/password combo. The problem is that both webdrivers seem to get stuck during username input for some reason.
I should mention that running either test by themselves works without issue, running both tests sequentially is also ok, so the problem only occurs when both tests are ran at the same time.
Also of note is if I try the same thing with two instances of Chrome Driver instead of Internet Explorer, again there is no problem. So this is something related to the IE webdriver and only when there are multiple instances of it at the same time.
Does anyone have any solution/idea that could solve this?
It has already been documented here as a known issue, and currently the only way to reliably do this using IEDriver is by using separate vms.

Selenium c# : How to work with manually opened browser using selenium c#

I would like to debug test scripts when ever failed. I dont want to run the entire test script from startng onwards (launching browser..logging )
If my browser already opened (manually) and I would like to click on some objects (Web) , how can I achieve this programatically using selenium. I can do this in QTP but I dont know how can achieve this in selenium. Appreciate your quick help. !!
I am using Selenium 3.3 & IE 2.53 driver for Internet explorer
In general, the answer is that you can't do this. WebDriver explicitly does not support attaching to an existing browser instance that it did not start. This is a general principle, but is also explicitly true for Internet Explorer. I know that's not the answer you wanted to hear, but that's the way the IE driver is written at present.
I have faced similar problems. I work with an applications that has more than 10 screens.
We came up with a solution where we did not closed the browser if we encounter any failure. Have a solid exception handling in place and do not call Close() or Quit() methods to close the browser session.
Refer the below to come up with the program to continue automation with the already opened session. This is pretty much possible depending on how you designed your Automation framwork.
How to use a already opened firefox for testing in Selenium
Work on firefox for debugging purposes and then you can run the same test with Internet explorer
Note : I will update the answer with C# program to work with existing browser instances.

Capturing URL while Selenium Tests run

i am automating using selenium webdriver and C#. Is there a way to capture all urls that my browser navigates to while my Selenium automation tests run using an external tool such as Fiddler core / wireshark. I mean while my tests continue to run, I would like some of these tools to capture my urls parallely so that incase my tests fail, i could investigate further by using the final few urls(from the point of failure) to debug the issue.
Is this really possible. Do I need to use a separate thread to one of these tools(Fiddler/wireshark/any other tool) to capture the url?
Can this really be done
There are a few options.
Start wireshark (or fiddler) before your Selenium test kicks off. You can do this with a batch file that gets executed in your test setup.
You can utilize a browser plugin for fiddler. IE has one, I'm not sure if there is a comparible plugin for all browsers though. Then you can get Selenium to activate this through the browser...assuming fiddler keeps in the browser window and not open a separate non-browser window that Selenium can't see.UPDATE: Fiddler plugins don't stay in the browser window so this option won't work.
Write some wrapper code that does a driver.Url and stores it into a list. This wrapper code would check to see if the driver.Url is different from the last stored entry in the object and if it is different then it would add it to the list.
All have pros and cons. 3 would give you the most control as your test itself would gather the URL's and maintain a list in code that you can do what you want with. 1 of course would give you the most robust details, depending on how you setup wireshark, and you can profile the entire machine and network experience. 2 is a middle ground where your test still drives it, but the results are separate...but being part of the browser you would have to avoid cleanup after your tests...if you have more tests than one execute at a time this could cause alot of problems...

Can you change IE document mode using Selenium WebDriver and C#?

I'm using WebDriver and Selenium Server 2.28. I'm running this on a Windows 7 environment, and the version of IE is 9.0.8.
I'd like to know if there is any way of forcing compatibility mode in IE using Selenium 2. I've googled this, and there doesn't seem to be a lot of information about this.
How about changing the properties and forcing IE to open in Compatibility mode until you are finished testing? You'll need to run as Admin.
Without further details it is hard to give specific details, but you can force IE into a specific compatibility mode using a special <meta> tag:
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
A value of EmulateIE7 will tell IE to evaluate the <!doctype> as if it'd be IE7. Other valid values would be IE7, IE8, IE9, or Edge, which will use the specific version's behavior.
Just keep in mind that the differences implied by this aren't necessarily 100% the same as when using the specific browser versions (but it should be very close especially regarding JavaScript/DOM and HTML).

Categories