Hi,I have to assert the expected error message with actual error message . But the error message in HTML source page has line break.I have used assert like this :assertEquals("The email is blank. Please enter an email!",driver.findElement(By.xpath(XXXXXXXX)).gettext());
Page Source :
<span class="ui-message-error-detail">The email is blank.<br/>Please enter an email!</span>note : If there is no line break tags , I can assert it. But due to line break I couldn't do it..script failing.Can anyone help me..Nax143
.. now obviously this xpath doesn't tell whether there is a BR in the span or not, but at elast it allow you to assert the content.
note there is no tspace between the '.' and work 'please'
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/xt9xq6dzWvsJ.--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
<div id="user-msg" class="ui-message-error ui-widget ui-corner-all"><span class="ui-message-error-icon"></span><span class="ui-message-error-detail">The email is blank.<br/>Please enter an email!</span></div>
Please send me the solution ...
Nax143str1=driver.findElement(By.xpath("//[@id='user-msg']/span[2]/text()[1]")).getText();
str2 =driver.findElement(By.xpath("//[@id='pass-msg']span[2]/text()[2]")).getText();
assertEquals("The email is blank. Please enter an email!",str1+" "+str2);
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/lflg4zxHpUQJ.
Hmm, that’s valid XPath, looks like we may have a bug.
I’ll double check later today.
--
It would seem I’m talking rubbish (obviously too late for me). I got as far as raising it as:
http://code.google.com/p/selenium/issues/detail?id=4158
But then stepped back and had another good look at the error message and thought, “I’m being an idiot, did I ever really do this in WebDriver? Or was it something I’ve done with Selenium RC a long time ago”.
And confirmed I’m talking rubbish on IRC:
<Ardesco> Hmm am I raising balls?
<Ardesco> http://code.google.com/p/selenium/issues/detail?id=4158
<Ardesco> I'm sure I used to be able to get WebElements this way, but I have a nasty feeling I'm getting my Selenium RC API locator startegies mixed up with WebDriver ones
<Dude-X> i never liked using text() in my xpath
<jarib> Ardesco: AFAIK using findElement() to find text nodes has never worked
<Dude-X> it works sometimes...
<Dude-X> actually hmm
<Dude-X> i always remove it when i find it :P
<Ardesco> I thought I had use it in the past, but now i'm doubting myself
<Ardesco> *used
<Ardesco> and I agree it's something to avoid if possible
<Dude-X> anyway use getText() on the element
<jarib> either improve the markup or just do getText().split("\n") on the span
<barancev> should wdSession.prototype.getWindow return the top window?
<Ardesco> feel free to close it
<Ardesco> and slap a muppet stamp on me
<Ardesco> :)
Should have confirmed it on IRC first really, silly me.
here is your problem:you forgot the '.' before the equal sign
//SPAN[.='The email is blank.Please enter an email!']
On Tue, Jun 26, 2012 at 2:07 PM, Nax143 <venkat...@adfonic.com> wrote:
When I tried lutfijd solution , I am getting following error:
The given selector //SPAN[='The email is blank.Please enter an email!'] is either invalid or does not result in a WebElement. The following error occurred:[java] [InvalidSelectorError] Unable to locate an element with the xpath expression //SPAN[='The email is blank.Please enter an email!'] because of the following error:
[java] [Exception... "The expression is not a legal expression." code: "51" nsresult: "0x805b0033 (NS_ERROR_DOM_INVALID_EXPRESSION_ERR)" location: "file:///var/folders/km/95m9f3rs28jfp_649qzlvsl40000gn/T/anonymous5457794172896486930webdriver-profile/extensions/fxdri...@googlecode.com/components/driver_component.js Line: 2621"]
To post to this group, send email to selenium-users@googlegroups.com.
To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.