Selenium C# integration With Neoload performance testing tool - c#

Could anyone help me to elaborate procedure for integrating selenium C# script with neoload tool.i wanted to integrate selenium C# and Appium C# coding with neoload .So I went though some steps in documentation and unable to run the example code and didn't get the point how we can integrated with selenium/appium C# script with neoload for chrome or any browser and perform load testing for web or mobile application with same tool .Could you please have a look on shared screen shot and help me to share valuable document with any simple example for understanding the concept/getting some confidence.Thanks for giving valuable time

I modified the code found here for the chrome driver: https://www.neotys.com/documents/doc/neoload/latest/en/html/#24364.htm
DesiredCapabilities cap = new DesiredCapabilities();
NLWebDriverFactory.AddProxyCapabilitiesIfNecessary(cap);
object proxyCapability = cap.GetCapability(CapabilityType.Proxy);
ChromeProfile profile = new ChromeProfile();
if (proxyCapability != null) {
profile.SetProxyPreferences(proxyCapability as Proxy);
}
ChromeDriver webDriver = new ChromeDriver(profile);
Your problem is that you need to provide the ChromeDriver with a profile which has the DesiredCapabilities whereas you try to apply them directly to the driver.

Related

Appium : how to test webappication in chrome on windows 10?

I am trying to automate tests for a web application running in chrome on Windows 10 using Appium.
I have code like below that works perfectly fine uses chromedriver. I want to move this to appium based approach.
RemoteWebDriver driver = new ChromeDriver(#"C:\Users\Administrator\Downloads\chromedriver_win32");
driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(60));
driver.Url = "https://www.bing.com/";
RemoteWebElement element = (RemoteWebElement)driver.FindElementById("sb_form_q");
element.SendKeys("webdriver");
element.SendKeys(Keys.Enter);
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(60));
wait.Until(x => x.Title.Contains("webdriver"));
I searched internet and find a lot of code to test webapplications on chrome on android emulators on windows devices. I did not find any sample that runs chrome browser directly on windows 10.
Based on what i understood, i tried adopting the code by making changes to desired capabilities like below.
DesiredCapabilities caps = DesiredCapabilities.Chrome();
caps.SetCapability(CapabilityType.BrowserName, "chrome");
caps.SetCapability(CapabilityType.Version, "60");
caps.SetCapability(CapabilityType.Platform, "Windows 10");
caps.SetCapability("platformName", "Windows");
//caps.SetCapability("app", #"C:\Users\Administrator\Downloads\chromedriver_win32\Chromedriver.exe");
caps.SetCapability("app", #"Chrome");
caps.SetCapability("deviceName", "WindowsPC");
driver = new RemoteWebDriver(new Uri("http://127.0.0.1:4725/wd/hub"), caps, TimeSpan.FromSeconds(60));
driver.Url = "https://www.bing.com/";
((IWebDriver)driver).Navigate().GoToUrl("https://www.bing.com/");
RemoteWebElement element = (RemoteWebElement)driver.FindElementById("sb_form_q");
element.SendKeys("webdriver");
element.SendKeys(Keys.Enter);
Thread.Sleep(5000);
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(60));
wait.Until(x => x.Title.Contains("webdriver"));
This however doesn't work.
I think the problem is I am not able to figure out how to set desired capabilities so that appium service running on http://127.0.0.1:4725/wd/hub is able to launch chromedriver and run tests.
Can someone please help point out mistake with the above code?
Appreciate your help.
you need to pass the capabilities of the android phone not the windwos pc as you passes
caps.SetCapability("platformName", "Windows");
Like that and you need to pass the OS version of the emulator or android phone if you are using it..
For reference visit this site you will know everything that you need to know..
http://www.automationtestinghub.com/launch-chrome-browser-on-mobile-device/
Happy to help.. let us know if that solution works for you
As nicely put up here - https://crossbrowsertesting.com/blog/appium/appium-native-web-hybrid-applications/
Appium is an open source test automation frameworktes that drives iOS and Android native, mobile, and hybrid apps using the WebDriver protocol a.k.a. The Selenium API. That’s to say, Appium is like Selenium’s cousin, and used for testing mobile apps instead of web applications in desktop browsers.
Per the discussion here - https://discuss.appium.io/t/can-appium-automate-desktop-web-browsers/746/5 too it seems appium is for testing on mobile devices only.

Appium with ChromeDriver to web view application

I'm new to Appium but I have experience with selenium.
I need to write tests for a web view app.
But when I need to find an element I need to use the UIAutomatorViewer and use it like it's a native app.
Is there a way to use the DOM to navigate like when I'm working with the Chrome browser?
I tried this:
AppiumDriver<IWebElement> driver;
DesiredCapabilities cap = new DesiredCapabilities();
cap.SetCapability("deviceName", "LG - SERVER SERVER's Orange - G3");
cap.SetCapability("apppackage", "com.essence.adlfamily");
driver = new AndroidDriver<IWebElement>(new Uri("http://127.0.0.1:4723/wd/hub"), cap);

cross browser testing using codedui?

i have issue in cross browser testing using codedui.
Using below code,
Process.Start("firefox", url);
BrowserWindow.CurrentBrowser = "firefox";
Browser = BrowserWindow.Launch(new System.Uri(url));
Keyboard.SendKeys("^{0}");
all code developed in IE . but now i have to execute code in firefox or chrome.I am going to execute the code in forefox.I am using this code here
Browser = BrowserWindow.Launch(new System.Uri(url));
in this line getting error like "An error occurred while connecting to Firefox".how to resolve this issue?I installed selenium components also. if i remove this line I am getting diffrent error like " Unable to find browser"...Please help.
Out of the box Visual Studio doesn't support cross browser CodedUI testing.
You're going to need to install Selenium components to allow for cross browser testing in Visual Studio.
Details on that can be found here:
http://blogs.msdn.com/b/visualstudioalm/archive/2012/10/30/introducing-cross-browser-testing-with-coded-ui-tests.aspx
Selenium components can be found here:
http://visualstudiogallery.msdn.microsoft.com/11cfc881-f8c9-4f96-b303-a2780156628d
Looks like CodedUI doesn't support playback on very many different browsers http://msdn.microsoft.com/en-us/library/dd380742(VS.100).aspx
There are some other tools out there http://watin.org/ is one, but I can't find anything myself that will really solve your problem.
Try
BrowserWindow.CurrentBrowser = "firefox";
BrowserWindow WebApp;
WebApp.CopyFrom(BrowserWindow.LaunchUrl(new System.Uri(url)));
I set up something similar to the following and it works well (I hand code everything, bypassing the UIMap).
public class WebApp : BrowserWindow
{
private string _url;
public WebApp(string url)
{
//define search properties using this keyword so the web application can be treated as a browser
_url = url;
BrowserWindow.CurrentBrowser = "Chrome";
this.CopyFrom(BrowserWindow.Launch(new Uri(url));
}
}
You can overload the constructor, of course, by adding a parameter for the browser to use or whether to start up the browser or not.
By setting up the web application as a BrowserWindow, you can have one open and ready and the playback engine should find it. I find this helps when working on tests (in IE).
Just a reminder, you do need the Selenium plug-in and that plug-in will only work for playback, not recording.
Cheers!
In our environment, we set up the Launch() method by doing the following:
public void LaunchBrowser(string uri)
{
BrowserWindow.CurrentBrowser = "firefox";
BrowserWindow myBrowser = BrowserWindow.Launch(new System.Uri(uri));
}
One thing to note is that if there is a firefox process already running in the background, the WebDriver will not launch a new instance, so be sure that all instances of firefox are shut down before the LaunchBrowser() is called. I've found that there are Java plugins that can keep it running in the background, so try to disable those that you don't need. Another good place to look, if you check your Task Manager and this is the case, is here.

c# headless browser with javascript support for crawler

Could anyone suggest headless browser for .NET that supports cookies and authomatically javascript execution?
Selenium+HtmlUnitDriver/GhostDriver is exactly what you are looking for. Oversimplified, Selenium is library for using variety of browsers for automation purposes - testing, scraping, task automation.
There are different WebDriver classes with which you can operate an actual browser. HtmlUnitDriver is a headless one. GhostDriver is a WebDriver for PhantomJS, so you can write C# while actually PhantomJS will do the heavy lifting.
Code snippet from Selenium docs for Firefox, but code with GhostDriver (PhantomJS) or HtmlUnitDriver is almost identical.
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Support.UI;
class GoogleSuggest
{
static void Main(string[] args)
{
// driver initialization varies across different drivers
// but they all support parameter-less constructors
IWebDriver driver = new FirefoxDriver();
driver.Navigate().GoToUrl("http://www.google.com/");
IWebElement query = driver.FindElement(By.Name("q"));
query.SendKeys("Cheese");
query.Submit();
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
wait.Until((d) => { return d.Title.ToLower().StartsWith("cheese"); });
System.Console.WriteLine("Page title is: " + driver.Title);
driver.Quit();
}
}
If you run this on Windows machine you can use actual Firefox/Chrome driver because it will open an actual browser window which will operate as programmed in your C#. HtmlUnitDriver is the most lightweight and fast.
I have successfully ran Selenium for C# (FirefoxDriver) on Linux using Mono. I suppose HtmlUnitDriver will also work as fine as the others, so if you require speed - I suggest you go for Mono (you can develop, test and compile with Visual Studio on Windows, no problem) + Selenium HtmlUnitDriver running on Linux host without desktop.
I am not aware of a .NET based headless browser but there is always PhantomJS which is C/C++ and it works fairly well for assisting in unit testing of JS with QUnit.
There is also another relevant question here which might help you - Headless browser for C# (.NET)?

How to take screenshot using Selenium RC using c# in IE8?

I am using Selenium RC using c# and need to take screenshot for the test case failed, I have to perform these test on IE 8.
I got lot of tutorials for Firefox but didn't find any for the IE8.
Thanks in advance.
You can use the Selenium Web Driver to take a screenshot of IE pretty easily. The code would look something like this:
IWebDriver driver = new InternetExplorerDriver();
driver.Navigate().GoToUrl("http://www.google.com");
TakeScreenshot(driver, #"C:\screenshot.png");
You can download the Web Driver here: https://code.google.com/p/selenium/downloads/list
Add it to your project and you are off and running.

Categories