I start use Selenium.WebDriver (v2.45) to run visual tests.
As web driver I use FirefoxDriver. I have installed Firefox 38. When I try run test firefox return exception with message:
FF has stopped working.
Does anyone have any suggestions? It worked in previous week, is it possible that my test was crashed by updated?
Problem signature:
Problem Event Name: APPCRASH
Application Name: Firefox.exe
Application Version: 38.0.1.5611
Application Timestamp: 55540a1a
Fault Module Name: xul.dll
Fault Module Version: 38.0.1.5611
Fault Module Timestamp: 55541969
Exception Code: c0000005
Exception Offset: 0035669b
OS Version: 6.3.9600.2.0.0.16.7
Locale ID: 1033
Additional Information 1: 5861
Additional Information 2: 5861822e1919d7c014bbb064c64908b2
Additional Information 3: a10f
Additional Information 4: a10ff7d2bb2516fdc753f9c34fc3b069
There is my test method body:
[Fact]
public void ShouldLoginForTestAccount()
{
var driver = new FirefoxDriver();
driver.Manage().Cookies.DeleteAllCookies();
driver.Navigate().GoToUrl(LoginPage);
driver.FindElementById("Login")
.SendKeys("correctLogin");
driver.FindElementById("Password")
.SendKeys("correctPassword");
driver.FindElementByTagName("button")
.Click();
Assert.Equal(TestingProjectUrl, driver.Url);
driver.Close();
}
Selenium 2.45 does not reliably work with Firefox 38 due to compatibility issues.
Downgrade Firefox to 35 (link to 35.0.1).
I have a suggestion.
I was getting the error bellow when I called Quit() method of WebDriver.
unknown software exception (0x80000003) em 0x55fdec79
So I created the WebDriver as follow:
FirefoxOptions foxOptions = new FirefoxOptions();
foxOptions.SetPreference("dom.allow_scripts_to_close_windows", true);
driver = new ThreadLocal<IWebDriver>(() => { return new FirefoxDriver(service as FirefoxDriverService, foxOptions, new TimeSpan(0, 1, 0)); }).Value;
Then, before call Quit() method, I execute one javascript to close the main window:
try { ((IJavaScriptExecutor)driver).ExecuteScript("window.close();"); } catch { }
So now I'm able to call Quit() without get any error. I know that this is a workaround, but I think this can help you.
Related
This code works fine against Chrome in local (i.e. on PC)...
IWebElement widget = Driver.FindElements(widgetLocator).FirstOrDefault(x => x.Displayed);
...but throws the following when used against Appium 1.9.1 to talk to Android 8.0.0:
OpenQA.Selenium.WebDriverException: 'An unknown server-side error occurred while processing the command. Original error: unknown error: Argument to isShown must be of type Element
(Session info: chrome=73.0.3683.90)
(Driver info: chromedriver=2.44.609538
The browser does start up on Android, navigates to the page within our site that it's supposed to, and in most ways works fine. But, Displayed always throws the above without further explanation. Have anyone seen this?
I've tried using ExecuteJavaScript() to check visibility the hard way, but in OpenQA.Selenium ExecuteJavaScript() returns void, not bool as on other platforms. I've tried, Enabled but that doesn't do what I was after. I've borrowed a colleague's IsElementVisible() function as below, but that throws as well:
public static bool IsElementVisible(IWebDriver driver, By locator)
{
WebDriverWait wait = new WebDriverWait(driver,System.TimeSpan.FromMinutes(1));
WebDriverWait w = new WebDriverWait(driver, TimeSpan.FromMinutes(1));
try
{
wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(locator));
}
catch (Exception ex)
{
return false;
}
return true;
}
And finally I've tried to FindElement on the element I'm looking for via CssSelector, ClassName and anything else I could think of, without success (they can't reliably only find the "visible" version of the element).
By way of background, what I'm trying to do here is to "port" some existing test scripts that work against Chrome on PC via WebDriver to test the same website on Android via Appium. This legacy code uses . Displayed in many places and if I can't find a reliable alternative in the mobile situation we'll have somewhat of a problem.
Please find the below code that i have edited
as you can see in your exception it says "Argument to isShown must be of type Element", it means what type of element you are passing please let us know if this solution worked
Exception:
OpenQA.Selenium.WebDriverException: 'An unknown server-side error occurred while processing the command. Original error: unknown error: Argument to isShown must be of type Element (Session info: chrome=73.0.3683.90) (Driver info: chromedriver=2.44.609538
Code Edited:
public static bool IsElementVisible(IWebDriver driver, String locator)
{
WebDriverWait wait = new WebDriverWait(driver,System.TimeSpan.FromMinutes(1));
WebDriverWait w = new WebDriverWait(driver, TimeSpan.FromMinutes(1));
try
{
wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.xpath(locator)));
}
catch (Exception ex)
{
ex.printStackTrace();
return false;
}
return true;
}
Upgrading to Appium WebDriver 4.0.0.4beta fixed the problem for me.
My OS Build: 16299.309 so
I download MS WebDriver, ver. 5.16299 release: 16299, from https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/
My SetEdgeDriver() method in C#:
private IWebDriver SetEdgeDriver()
{
try
{
var path = #"C:\FolderWhereMSWebDriverExeFile ";
var option = new EdgeOptions();
option.PageLoadStrategy = PageLoadStrategy.Normal;
return new EdgeDriver(path, option);
}
catch (Exception)
{
throw;
}
}
When the unit test is executed, Edge browser opens briefly then it closes with an error saying "Unexpected error. Unknown error"
The test is just about going to Google search site and works fine with Chrome.
I have followed this: Edge browser crashing after initial watir-webdriver launch
but no luck. Please advice.
You can try a different constructor:
IWebDriver wrappedWebDriver = new EdgeDriver(new EdgeOptions());
This works for me. No need to specify the folder. Also, think that the normal search patter is the default one.
I'm learning Selenium WebDriver and trying to run a simple test using Firefox 50 and Webdriver 3.0.1. I'm using Marionette driver 0.11.1
I have the following code:
FirefoxDriverService service = FirefoxDriverService.CreateDefaultService(#"P:\Selenium Practice\FirefoxDriver", "wires.exe");
service.FirefoxBinaryPath = #"C:\Program Files\Mozilla Firefox\firefox.exe";
FirefoxOptions options = new FirefoxOptions();
options.AddAdditionalCapability(CapabilityType.AcceptSslCertificates, true);
TimeSpan time = TimeSpan.FromSeconds(10);
IWebDriver driver = new FirefoxDriver(service, options, time);
driver.Navigate().GoToUrl("http://www.demoqa.com");
When running it, I'm getting the following exception with error code 10022:
It says:"An unhandled exception of type 'System.Net.Sockets.SocketException' occurred in System.dll"
I'm not really getting what I'm doing wrong. I went throw a lot of suggestions and none of those really worked. The last one that I describe here is that one: Setting up Marionette/ GeckoDriver
What can I do to fix it?
It's needed to select the second item from the drop-down menu that is hidden by default. The problem it that it works fine in Fire Fox 41 browser but not in Internet Explorer 11. I'm using Selenium Web Driver with C#, nUnit in Visual Studio 2010. Tests are executed on remote VM with Selenium Server and IEDriver.
HTML looks like:
<ul id="CVC" class="buttonMenu" style="visibility: hidden; left: 183px;">
<li class="menuItem">First</li>
<li class="menuItem">Second</li>
<li class="menuItem">Third</li>
</ul>
I have C# code that works only in FireFox:
var menu = wd.FindElement(By.Id("CVC"));
var menuLi = menu.FindElements(By.TagName("li"));
menuLi[1].Click();
wd.FindElement(By.Id("TITLE")).SendKeys("blabla"); //continue to work with appeared pop-up
wd.FindElement(By.Id("CVC_OK")).Click();
When I run test in Internet Explorer an error appears:
Test Name: Bookmark
Test FullName: EEE.Tests.BT.BB
Test Source: d:\Selenium\Automation\EEEAutomation\EEEAutomation\Tests\BT.cs : line 19
Test Outcome: Failed
Test Duration: 0:00:39.319
Result Message: OpenQA.Selenium.ElementNotVisibleException : Cannot click on element (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 35 milliseconds
Build info: version: '2.47.1', revision: '411b314', time: '2015-07-30 03:03:16'
System info: host: 'wkqacl0801', ip: '10.101.6.104', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_60'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities [{browserAttachTimeout=0, enablePersistentHover=true, ie.forceCreateProcessApi=false, pageLoadStrategy=normal, ie.usePerProcessProxy=false, ignoreZoomSetting=false, handlesAlerts=true, version=11, platform=WINDOWS, nativeEvents=true, ie.ensureCleanSession=false, elementScrollBehavior=0, ie.browserCommandLineSwitches=, requireWindowFocus=false, browserName=internet explorer, initialBrowserUrl=http://localhost:39901/, takesScreenshot=true, javascriptEnabled=true, ignoreProtectedModeSettings=false, enableElementCacheCleanup=true, cssSelectorsEnabled=true, unexpectedAlertBehaviour=dismiss}]
Session ID: 6f09c88a-bd73-4cab-9312-0587c8345023
Result StackTrace:
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at EEE.Tests.SubTests.CreateBBSubTest.Execute(IWebDriver wd) in d:\Selenium\Automation\EEEAutomation\EEEAutomation\Tests\SubTests\CreateBBSubTest.cs:line 103
at EEE.Tests.BT.BB() in d:\Selenium\Automation\EEEAutomation\EEEAutomation\Tests\BT.cs:line 54
Does anyone know how to make it worked in Internet Explorer 11?
Not sure if IE should be considered as a real browser. In any case I reread your problem, it seems that you expect IE to work like a browser on click event. In that case you might want to help it along :
using (var wd = new InternetExplorerDriver(
new InternetExplorerOptions {EnableNativeEvents = false}))
{
//your code
}
I figured out the solution by using JavaScript. I'm not sure that this is the best solution but at least it works not only in FF, but also in IE browser:
((IJavaScriptExecutor)wd).ExecuteScript("$('#CVC li:eq(1)').click()");
wd.FindElement(By.Id("TITLE")).Clear();
wd.FindElement(By.Id("TITLE")).SendKeys("blabla");
wd.FindElement(By.Id("CVC_OK")).Click();
This worked for me:
_driver.FindElement(By.Id("IdOfControl")).SendKeys(value);
Hi when i use the following code
IWebDriver _webDriver = new RemoteWebDriver(new Uri("http://127.0.0.1:4444/wd/hub"),
DesiredCapabilities.Chrome());
I get the follwing error
System.InvalidOperationException : The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see http://code.google.com/p/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://code.google.com/p/chromedriver/downloads/list
TearDown : System.NullReferenceException : Object reference not set to an instance of an object.
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
at Testframework.Browser.RemoteGoto(String browser, String url) in Browser.cs: line 86
at Testframework.CommonAction.RemoteBrowser(String browser) in CommonAction.cs: line 70
at Test.RegistrationTest.InvalidRegistrationTest(String browser, String username, String password, String confirmPassword, String securityQuestion, String securityAnswer, String errorMessageText, String firstname, String lastname) in RegistrationTest.cs: line 50
--TearDown
at Testframework.CommonAction.CaptureScreen(String fileName) in CommonAction.cs: line 121
at Test.RegistrationTest.SnapshotOnFailure() in RegistrationTest.cs: line 590
The clue really is in the error.
Chrome should be installed on the system where the tests are either running on or being pointed to.
Take a step back, look at the documentation:
https://code.google.com/p/selenium/wiki/ChromeDriver
Also, if Chrome is installed in a peculiar place, you'll need to point Selenium to it's location. Again, this is explained in the documentation.
In C#:
DesiredCapabilities capabilities = DesiredCapabilities.Chrome();
capabilities.SetCapability("chrome.binary", this.binaryLocation);
or:
ChromeOptions options = new ChromeOptions();
options.BinaryLocation = "pathtogooglechrome";
capabilities.SetCapability(ChromeOptions.Capability, options);
Instead of changing the code you can have other way round.
Download the chrome driver and set the PATH environment variable pointing to the directory where the chromedriver.exe is present.
Restart your IDE / Command console and run the tests. It works!!!