The first click is throwing the error. This has worked many times before. Now, it's not working. I checked the class names and they are the same.
At the first wait.Until (drv) line it throws the error
" An unhandled exception of type 'System.InvalidOperationException'
occurred in WebDriver.dll Additional information: unknown error:
Element is not clickable at point (-1469, 66)"
System.Threading.Thread.Sleep(7000);
// Now Click Next (Broke here first time)
wait.Until(drv => drv.FindElements(By.ClassName("compareSelectedAddToMyBriefcaseAddToBOMLabels"))[1]).Click();
// Click Next Again
System.Threading.Thread.Sleep(10000);
wait.Until(drv => drv.FindElements(By.ClassName("compareSelectedAddToMyBriefcaseAddToBOMLabels"))[0]).Click();
// Click Continue
System.Threading.Thread.Sleep(10000);
Anyone using ChromeDriver 61+ may run into this error. The recent update of the ChromeDriver V2.32 fixes this issue. I recommend updating your ChromeDriver. This should do the trick.
Related
I have this linq query which works perfectly fine but sometimes it throws exception, following is start :
query = table.Include(x=>x.table2)
after applying few conditions in code finally following is the line which throws exception :
var data = await query.Skip(offset).Take(filter.PagingOption.PageSize).AsNoTracking().ToListAsync();
ErrorDetail :
System.Data.SqlClient.SqlException (0x80131904): The column 'Id' was specified multiple times for 't'.\r\n
Mostly it is observed that when IIS is restarted error occurs, but once the error is occurred on refresh this works totally fine. Which I guess is random behavior.
Any ideas ?
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.
I am hoping that someone who has worked with ArangoDB and .Net and C# can help me out.
When I call ArangoClient.AddConnection() an exception gets thrown (of type 'System.ArgumentException' occurred in mscorlib.dll). The message is "An item with the same key has already been added."
The call to ArangoClient is: ArangoClient.AddConnection("127.0.0.1", 8529, false, "NancyTest", "NancyTest", "root");
Any ideas?
You most probably already created a connection with specified alias. With a driver version 0.9.0 and higher you can check if the specified alias already exists through ASettings.HasConnection(string alias) static method.
I have problem with webdriver on IE9 (win7, c#, selenium 2.3). I get NoSuchWindowException exception.
I found that I need to change 'Enable Protected Mode' for all Security Level to the same value. But I don't want to change my settings generally and manually, just programmatically for time of testing. I thought that I've just need to set IntroduceInstabilityByIgnoringProtectedModeSettings to true and it will be working, but it doesn't. My code (these lines work ok):
var option = new InternetExplorerOptions();
option.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
IWebDriver Driver = new InternetExplorerDriver(option);
Driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));
Driver.Navigate().GoToUrl(baseUrl);
This cause exception:
Driver.Manage().Window.Maximize();
An exception of type 'OpenQA.Selenium.NoSuchWindowException' occurred in WebDriver.dll but was not handled in user code
Additional information: Error retrieving window with handle current
also this:
string pageSource = Driver.PageSource;
An exception of type 'OpenQA.Selenium.NoSuchWindowException' occurred in WebDriver.dll but was not handled in user code
Additional information: Unable to get browse
Do you have idea what is going wrong/what can I do to run my test?
-Hello, thank you for reading my post. I have spent all day trying to figure this out. Just trying to click the above element to iterate to the next page of product reviews (this doesn't change the URL). The element corresponds to the "next" button on the product feedback section of the page.
Here is My code:
using OpenQA;
using OpenQA.Selenium;
using OpenQA.Selenium.Support;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Support.UI;
using OpenQA.Selenium.IE;
....
IWebDriver driver = new FirefoxDriver();
driver.Navigate().GoToUrl("http://www.aliexpress.com/item/Wholesale-DIY-Cardboard-Hang-tag-Retro-Gift-Hang-tag-500pcs-lot-Free-shipping-Thank-you/538222647.html");
driver.FindElement(By.XPath("/html/body/div[3]/div[10]/div[2]/div[2]/div/div/ul/li[2]/a")).Click();
The above click command is just to open the product feedback section of the webpage (it works). Next I just want to select the next page of the product feedback but haven't been successful.Below are some commands that I've tried to click the next button and move to the next page of the product feedback listings. I'm new to programming, as you can probably see.
driver.FindElement(By.XPath("/html/body/div/div[2]/div/div[2]/div/a[3]")).Click();
NoSuchElementException was unhandled: Unable to locate element: "method":"xpath","selector":"/html/body/div/div[2]/div/div[2]/div/a[3]"}"
driver.FindElement(By.XPath("//a[contains(#class,'page-next')]")).Click();
NoSuchElementException was unhandled:Unable to locate element: {"method":"xpath","selector":"//a[contains(#class,'page-next')]"}
driver.FindElement(By.XPath("/html/body/div/div[2]/div/div[2]/div/a[#href='javascript:gotoPage(2)]")).Click();
InvalidSelectorException was unhandled: The given selector /html/body/div/div[2]/div/div[2]/div/a[#href='javascript:gotoPage(2)] is either invalid or does not result in a WebElement. The following error occurred:
InvalidSelectorError: Unable to locate an element with the xpath expression /html/body/div/div[2]/div/div[2]/div/a[#href='javascript:gotoPage(2)] because of the following error:
[Exception... "The expression is not a legal expression." code: "12" nsresult: "0x805b0033 (SyntaxError)" location: "file:///C:/Users/Danny/AppData/Local/Temp/anonymous695678260.webdriver-profile/extensions/fxdriver#googlecode.com/components/driver_component.js Line: 5773"]
driver.FindElement(By.XPath("//a[#href='javascript:gotoPage(2)]")).Click();
InvalidSelectorException was unhandled: The given selector //a[#href='javascript:gotoPage(2)] is either invalid or does not result in a WebElement. The following error occurred:
InvalidSelectorError: Unable to locate an element with the xpath expression //a[#href='javascript:gotoPage(2)] because of the following error:
[Exception... "The expression is not a legal expression." code: "12" nsresult: "0x805b0033 (SyntaxError)" location: "file:///C:/Users/Danny/AppData/Local/Temp/anonymous2137829175.webdriver-profile/extensions/fxdriver#googlecode.com/components/driver_component.js Line: 5773"]
driver.FindElement(By.LinkText("2")).Click();
No error here, but this code clicks the wrong button on the page.
driver.FindElement(By.LinkText("javascript:gotoPage(2)")).Click();
NoSuchElementException was unhandled: Unable to locate element: {"method":"link text","selector":"javascript:gotoPage(2)"}
driver.FindElement(By.TagName("a")).FindElement(By.LinkText("Next")).Click();
NoSuchElementException was unhandled: Unable to locate element: {"method":"link text","selector":"Next"}
driver.FindElement(By.CssSelector("html body.product-evaluation div#transction-feedback div.rating-detail div.topnav div#pagination-top.pagination div.pos-right a.page-next")).Click();
NoSuchElementException was unhandled: Unable to locate element: {"method":"css selector","selector":"html body.product-evaluation div#transction-feedback div.rating-detail div.topnav div#pagination-top.pagination div.pos-right a.page-next"}
IJavaScriptExecutor JavascriptExecutor = driver as IJavaScriptExecutor;
JavascriptExecutor.ExecuteScript("gotoPage(2)");
"Unexpected error. ReferenceError: gotoPage is not defined"
driver.FindElement(By.XPath("//a[contains(text(),'Next')]")).Click();
No error, nothing happens
driver.FindElement(By.CssSelector("css=a.page-next")).Click();
InvalidSelectorException was unhandeled:The given selector css=a.page-next is either invalid or does not result in a WebElement. The following error occurred:[Exception... "An invalid or illegal string was specified" code: "12" nsresult: "0x8053000c (NS_ERROR_DOM_SYNTAX_ERR)" location: "file:///C:/Users/Danny/AppData/Local/Temp/anonymous797491401.webdriver-profile/extensions/fxdriver#googlecode.com/components/driver_component.js Line: 7717"]
driver.FindElement(By.XPath("//div[#id='pagination-top']/div/a[2]"));
NoSuchElementException was unhandled:Unable to locate element: {"method":"xpath","selector":"//div[#id='pagination-top']/div/a[2]"}
I've also tried:automation in Internet Explorer, and waiting for the page to load fully before proceeding.
The following is the situation I am focusing on:
driver.FindElement(By.XPath("//a[contains(#class,'page-next')]")).Click();
NoSuchElementException was unhandled:Unable to locate element: {"method":"xpath","selector":"//a[contains(#class,'page-next')]"}
I would suggest that you must add in a method prior to searching for the element, to wait for its existence on the page. I feel that the element you are searching for has not been loaded on the page by the time you try to search for it so Selenium instantly fails. I would suggest going to this link and using either an Implicit or Explicit wait. I feel this is the issue because your XPath looks correct according to the HTML in your title.
The difference between these is that Implicit waits are set for each time you search for an element only while Explicit waits can have any condition to wait for and can have a different timeout for each case. Read the link provided and see if it makes sense, if not please post your attempt and I will try to help.
I experienced this problem today with the following xpath:
//a[#class='myclass' and Text()='My Special link']
I was supposed to verify the syntax in firebug using the xpath tool, and it found the element. In java code it thrown the very same exception as you. I discovered the lil thing that was wrong was "Text()" I changed it to "text()" and it works. Subtle case sensitive problem lol.
I also saw in another forum a similar syntax issue, like:
//[#class='myclass' and Text()='My Special link']
I guess the person wanted to find anything with class "myclass", it didn't work. It worked when an * was added, though.
//*[#class='myclass' and Text()='My Special link']
Take a look to the syntax of your xpath,
cheers!