0

I am trying to get the return value of the div modal popup dialog. However, I could not get the value by using the

selenium.GetAttribute("id=lblPopUpMessageType");

What I wish to achieve is when I able to get the value then I can catch whether which progress is done.

For example, the code is like below:

 <span id="lblPopUpMessageType">error</span>  (If i get the "error" value i know it is fail) 
or 
 <span id="lblPopUpMessageType">success</span> (This mean success)

Well, I am not able to get by using the above function. I also tried with Selenium.GetElementIndex().ToString() but not working. I am new to Selenium, any help would be appreciate. Thank you!

Ripon Al Wasim
  • 36,924
  • 42
  • 155
  • 176
fj123
  • 963
  • 1
  • 8
  • 11

1 Answers1

2

Use selenium.getText("xpath to ur span") rather than using selenium.getAttribute.

As getAttribute() method gives the value of an attribute within any given tag.

Amey
  • 8,470
  • 9
  • 44
  • 63
Abhishek_Mishra
  • 4,551
  • 4
  • 25
  • 38
  • thank you for reply... but it still return me nothing... i tried with string abc=selenium.GetText("xpath=lblPopUpMessageType"); i return abc in a textbox.. it give me null value – fj123 Nov 21 '12 at 05:52
  • write it as selenium.getText(//span[@id='lblPopUpMessageType']).The way you are writing xpath is wrong.You can also refer tools like Firepath and Xpath checker for getting xpath. If you are not comfortable with xpath you can also write it as selenium.getText("id=lblPopUpMessageType").But in that case the id must be unique in whole page. – Abhishek_Mishra Nov 21 '12 at 06:55
  • hi Abhi, i tried with your selenium.getText(//span[@id='lblPopUpMessageType']) but it give me comment out of the rest of the sentence... any idea? I also tried with 2nd method but it still return nothing...in addition , the div that store this span id is invisible status, it will only give value when the modal dialog show up with error/success... – fj123 Nov 21 '12 at 08:29
  • i am using visual basic 2010. Comment out mean the words after // all become green in color... – fj123 Nov 21 '12 at 08:42
  • Ohh Got you..actualy You hav to pass it as string. selenium.getText("//span[@id='lblPopUpMessageType']"); – Abhishek_Mishra Nov 21 '12 at 08:55
  • i tried with selenium.getText("//span[@id='lblPopUpMessageType']"); and selenium.getText("id=lblPopUpMessageType") but why they are giving me "" value still? @@ – fj123 Nov 21 '12 at 09:14
  • It may be that when you are getting the text from span there is "" associated with that and it is changed to 'error' or 'success' after some event or action.Wait for that event or action to be completed. – Abhishek_Mishra Nov 21 '12 at 09:20
  • thank you ahbi ...but i wait until whole program finish... it return me nothing still.. – fj123 Nov 22 '12 at 02:53