0

First-all, I apologize if this question is already answered. I am trying to automate simple login page for aribaweb application. The following source of my web page for login label.

<td class=ffl>
<label for=_$eseed>Login Name:</label></td>

Java source code: I am trying to find out with below piece of code. But, I am not able to go through.

iedriver.findElement(By.id("Login Name")).sendKeys("username"); 

I have tried using IDE as well, to check label value. I am seeing same issue [error] Element id=_$eseed not found

Any help in this regard is much appreciated.

1
  • Please put the entire source of the specific element that you are trying to access (or even provide the URL of the web-page itself), and will be able to give you an answer. The problem is probably that "Login Name" is not the ID of the input element to which you are trying to send "username". Commented Jan 28, 2014 at 13:34

2 Answers 2

3

Can you give whole source code?

I think this is where the problem is:

iedriver.findElement(By.id("Login Name")).sendKeys("username");

is wrong. You should give your HTML element id to By.id. Not your label string.

You can use FireBug to find HTML elements ids,css and more.

Sign up to request clarification or add additional context in comments.

4 Comments

Sure @Ant's. Here is the source code: code public static void main(String[] args) { WebDriver iedriver = new FirefoxDriver(); iedriver.get("192.168.250.112:8085/EasyCare/AribaWeb/"); try { Thread.sleep(4000); } catch (Exception e) { // TODO: handle exception } iedriver.findElement(By.id("Login Name")).sendKeys("username"); iedriver.findElement(By.id("Password:")).sendKeys("passwd"); iedriver.findElement(By.id("Login")).click(); }
By.id("Login Name") is wrong. Your passing label to id, instead of id of that html element.
OK! Is this right way to do that? iedriver.findElement(By.id("_$seed")).sendKeys("username"); But, still says it Unable to locate element
No. Its not. Ok fine, there is no id to your html element. Try xpath instead.
0

Login Name: is not an id attribute. It is text. Instead you need to use the for attribute to locate the element. The other important thing is that you CANNOT send keys to label tags. There must be an input tag (or equivalent) next to the label where you want to send the text to.

WebElement label = driver.findElement(By.cssSelector("label[for='_$eseed']"));
s.o.p(label.getText());

If you provide html around the label consisting of input, I could point you on how to send keys.

Edit Based on your html, this is what you need,

WebElement login = driver.findElement(By.id("_$eseed"));
login.sendKeys("my_username");

5 Comments

<label for=_$eseed>Login Name:</label></td> <td class=ffi><span id=_fbgoob><img alt="" border=0 height=11 width=10 src=""></span></td> <td class=ffp> <input bh=TF class="tf tfW" value="" id=_$eseed type=text name=_2nakec><div class=rr id=_1cpb1c> </div> <tr id=_wmqizc valign=middle> <td class=ffl> <label for=_jbshdb>Password:</label></td> <td class=ffi><span id=_hhegnd><img alt="" border=0 height=11 width=10 src="/h.gif"></span></td> <td class=ffp> <input autocomplete=false onCopy="return false" xkeypress="return ariba.Handlers.noCapsLockTxt(event,this, '_l3onid');"
Thank you for response! Works like Gem!!
1 mre Q: I am not able to see Id for button, in this case, how to find the same Appreciate your help! tr id=_vez9u valign=middle> <td class=ffl> </td> <td class=ffi><span id=_hketcc><img alt="" border=0 height=11 width=10 src="gif.f"></span></td> <td class=ffp> <table border=0 cellpadding=0 cellspacing=0 class=btnWrap><tr><td tabIndex=0 bh=TB id=__vogkb class=btn _cl=btn _isdef=true><div class=rbSA><b class="rbC"><b class="rbBC rb1"></b><b class="rbBC rbFC rb2"></b></b><div class="rbBC rbBFC rbB"> Login </div><b class="rbC"><b class="rbBC rbFC rbBtFC rb2"></b><b class="rbBC rb1"></b></td></tr>
@user2943946 Please ask a separate question. Posting html in comment is not helpful and recommended. Format html like a code block and post a new question. I would be happy to help.
Apologies for the same. I have tried multiple things. I got thru, Tq! for your help!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.