0

I write test in selenium. I have span element. When user select text in this span and press ctrl+c, in this page will popup windows. But how can I select this text programmatically? I tried two way: use selenium call webElement.Click() 3 times. Because I know, if three times click by span, then will select all text in this span. But it throw exception, that System.InvalidOperationException: unknown error: Element is not clickable at point Also I tried programmatically via c# move and click cursor. But problem is, that in virtual machine in test agent, the cursor doesn't move. So Can you help me select text in span?

Maxim Petrov
  • 309
  • 1
  • 2
  • 11

2 Answers2

2

Why make the task way more complicated than it should be? You can make this simpler by doing:

String text = driver.findElement(By.id("theSpanElementId")).getText();
// now you have the text from the <span> element stored.
ddavison
  • 28,221
  • 15
  • 85
  • 110
0

In C#,

string spanText = driver.findElement(By.Id("SomeElementId")).Text;
amitbobade
  • 500
  • 1
  • 4
  • 15