I'm currently testing content within google documents using selenium webdriver. Some of my tests involve selecting individual words within a google document then performing some action against them such as bold the word or change the font type for the specific word etc.
I would simply like to be able to select a word like this:
And here is the code returned from the Google document:
I have tried using send keys to send a ctrl+a command and this works for me but the problem is, I need to do a little house keeping prior to running my test by creating a document with one word inside it. Kind of defeats the purpose of automating this.
I have tried using substring to get specific words but then I can't perform any action on the String as it will not be a web element.
Would someone be so kind and point me in the right direction? Thanks very much for any help. It is much appreciated.
1 Answer
Selenium can only manipulate WebElement
In your example you won't be able to manipulate only "is" which is a text, not a HTML node.
The best you can do is selecting the <span>:
driver.findElement(By.xpath("//span[contains(text(),'This is a paragraph')]")); and do whatever you want with it
4