I am using selenium web driver with C# and on trying to select an item on the available list I am receiving an error as:
ERROR: Caught exception [ERROR: Unsupported command [addSelection |
Can someone help me with this? Any workaround?
What I am trying is to select an item from a list which is on the left side and then click on the button (>) to move it to the right side.
You are getting the error because not everything in the IDE can be converted into the WebDriver API's.
You have to think about this logically, and not rely on the IDE to start generating this code for you.
The C# bindings have a
SelectElement
class, insideOpenQA.Selenium.Support
namespace, you'll need to add a reference to theWebDriver.Support.dll
assembly.It encompasses 'common' use cases for
select
elements. With this, you can probably mimic the behaviour ofaddSelection
. I haven't used the IDE so am not sure what that command is intended to do, but you can simply do something like:Select selectbox= new Select(driver.findElement(By.id("MY ID"))); selectbox.selectByIndex(2);