ERROR: Caught exception [ERROR: Unsupported comman

2019-07-21 07:03发布

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.

2条回答
Animai°情兽
2楼-- · 2019-07-21 07:22

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, inside OpenQA.Selenium.Support namespace, you'll need to add a reference to the WebDriver.Support.dll assembly.

It encompasses 'common' use cases for select elements. With this, you can probably mimic the behaviour of addSelection. I haven't used the IDE so am not sure what that command is intended to do, but you can simply do something like:

IWebElement element = driver.FindElement(By.Id("a"));
SelectElement select = new SelectElement(element);
select.SelectByValue("2");
select.SelectByText("George");
select.SelectByIndex(1);
查看更多
放我归山
3楼-- · 2019-07-21 07:33

Select selectbox= new Select(driver.findElement(By.id("MY ID"))); selectbox.selectByIndex(2);

查看更多
登录 后发表回答