Reputation: 33
Here is the html box I am trying to click onto,
<div style="min-height: 100px;" class="fr-element fr-view" dir="ltr"
aria-disabled="false" spellcheck="true"
contenteditable="true">
<p><br></p>
</div>
Then trying to reply with this button
<button type="submit" class="button--primary button button--icon button--icon--reply">
<span class="button-text">
Post reply
</span>
</button>
Here is what I have tried
WebElement Post;
Post = driver.findElement(By.xpath("//input[contains(@class,'fr-element fr-view']"));
Post.click();
Post.sendKeys("okay");
driver.findElement(By.xpath("//button//span[text()='Post reply']")).click();
Upvotes: 1
Views: 1989
Reputation: 176
You can use CSSSelector to click an element. Here is an example for c#
_driver.FindElement(By.CssSelector("a.ng2-smart-page-link.page-link.page-link-next"));
Another recommendation, you may try to use Katalon Recorder
See Details and Download at
https://chrome.google.com/webstore/detail/katalon-recorder/ljdobmomdgdljniojadhoplhkpialdid
It is used for creating script based on your action while recording. So that you can search solution for selecting by ID, Class, or CSSSelector.
Upvotes: 1
Reputation: 2755
Your input element is a div and you were missing the closing round bracket on your contains expression.
The following should work:
Post = driver.findElement(By.xpath("//div[contains(@class,'fr-element fr-view')]"));
You should test out the xpaths in the browser console as a sanity check. In Chrome just right click and click Inspect (ctrl + shift + i). Then go over to Elements tab and search (ctrl + f) on the elements using your xpath/css selector.
Hope this helps!
Upvotes: 1