I have a site where my script changes language on the site. To verify that the script ends up on correct page I want to verify that body class contains correct locale, SWE, GB, USA and so on. But I don't find a way of catching the value between class=" ">. When I using :tag_name .text i got all text on the page. And if I use :class I need to know the locale... test = driver.find_element(:tag_name, "body").text #Take all text on the site puts test ###E.G"### <body class="SWE"> <body class="GB"> <body class="USA"> Any suggestion of how I can do it? Best Regards Mattias
on 2013-03-15 15:01
on 2013-03-15 15:09
You can use `XPATH` with "selenium-webdriver". I hope that will work. You didn't give here the html code.If you provide I can give you a better idea. Thanks
on 2013-03-15 16:07
If you give the HTML to Nokogiri you should be able to search it much more accurately. Also, if you haven't tried it, give Watir-Webdriver a try. There's a much better API which should give you more flexibility when searching.
on 2013-03-15 16:52
On Fri, Mar 15, 2013 at 9:01 AM, Mattias A. <lists@ruby-forum.com> wrote: > puts test > > -- > Posted via http://www.ruby-forum.com/. > If you assign test to the element, instead of just the text of the element, the attributes should be available as test[:id], test[:class] and so on...
on 2013-03-17 17:02
Love U Ruby wrote in post #1101766: > You can use `XPATH` with "selenium-webdriver". I hope that will work. > You didn't give here the html code.If you provide I can give you a > better idea. > > Thanks Thanks for your reply! You can see the html below. 1. When you click Swedish, SWE turns up in the body class. <html> <head>...</head> <body class="SWE">...</body> </html> 2. when you click English, GB turns up in the body class. <html> <head>...</head> <body class="GB">...</body> </html> Ans so on. Thanks in advance Mattias
on 2013-03-17 17:10
tamouse mailing lists wrote in post #1101784: > On Fri, Mar 15, 2013 at 9:01 AM, Mattias A. <lists@ruby-forum.com> > wrote: >> puts test >> >> -- >> Posted via http://www.ruby-forum.com/. >> > > If you assign test to the element, instead of just the text of the > element, the attributes should be available as test[:id], test[:class] > and so on... A big thank you!! It worked to use test[:class] :D Best Regards Mattias
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.