0

How to extract text from tag using Selenium pageobject?

This is the html code:

<div class="post-actions__body" style="display: block;">
  <span class="title">Reply from:</span>

<input class="account-input" value="" disabled="">

<textarea class="reply-text-area"></textarea>

<a class="btn-post-message btn--inactive" href="#">Post</a>

<!--<span class="character-count">63206</span>--></div>

I’m trying to extract text from the input tag: input class="account-input" value="" disabled="", the text (“account one”) is visible on the GUI.

This is how I define the pageobject:

div(:reply_account, :css => '.post-actions__body .account-input')

I’ve tried using reply_account_element.getText(), .getValue(), .getAttribute(), but none of them work. Please advise, thanks!

chen layton
  • 61
  • 1
  • 7

1 Answers1

0

Have you tried:

text(:reply_account, :class => 'account-input')

reply_account = 'some value'
puts reply_account #should print 'some value'

Honestly I would suggest asking for an ID for the tag if possible but that is more of a personal best practices sort of thing.

GetBackerZ
  • 448
  • 5
  • 12