HOW
TO CAPTURE TOOL TIP MESSAGE IN SELENIUM WEB DRIVER:
Tooltip is nothing but an Advice Message to the User
(or) Helper Text.
For example In Gmail Signup Page while you are
clicking or entering username or Password helper text appears, those text
messages are called Tooltip messages.
Steps
to read tooltip message:
1. Open browser, enter your application URL (www.gmail.com
in this example)
2. Click on the Web element (Password field in this
example)and mouse Hover to that tooltip text (Mouse Hover can be performed by
using Actions(C) or JavaScript Executor(I)).
3. call get Text() on that mouse hovered Web Element
,store the value in String format and print on the console.
4. Verify with Actual text with Expected result.
Sample Program for reading or capturing the tool tip
message :
package
com.rameshsoft.demos;
import
java.util.concurrent.TimeUnit;
import
org.openqa.selenium.By;
import
org.openqa.selenium.JavascriptExecutor;
import
org.openqa.selenium.WebDriver;
import
org.openqa.selenium.WebElement;
import
org.openqa.selenium.firefox.FirefoxDriver;
import
org.testng.annotations.Test;
public class
CaptureTooltipDemo {
WebDriver driver;
@Test
public void mm() throws InterruptedException
{
System.setProperty("webdriver.gecko.driver", "C:\\Users\\ramesh\\Desktop\\desktop1\\java\\desk\\geckodriver-v0.11.1-win64\\geckodriver.exe");
driver=new
FirefoxDriver();
driver.manage().timeouts().implicitlyWait(15,
TimeUnit.SECONDS);
driver.manage().deleteAllCookies();
driver.get("https://accounts.google.com/SignUp?service=mail&continue=https%3A%2F%2Fmail.google.com%2Fmail%2F<mpl=default");
Thread.sleep(2000);
//click on Password
driver.findElement(By.xpath(".//*[@id='Passwd']")).click();;
WebElement ele=driver.findElement(By.xpath("html/body/div[3]/div[1]/div[2]"));
//perfroming mouseHover
mouseHOver(ele);
String ActualText="at
least 8 characters. Don’t use a password from another site, or something too
obvious like your pet’s name. Why?";
String expectedText=ele.getText();
System.out.println("text
is: "+expectedText);
if(ActualText.equalsIgnoreCase(ele.getText()))
{
System.out.println("Both
Actual and Expected values are
Equal");
}
else
{
System.out.println("Both
Actual and Expected values are not Equal");
}
}
public void mouseHOver(WebElement ele)
{
String mouseOverScript = "if(document.createEvent){var
evObj = document.createEvent('MouseEvents');evObj.initEvent('mouseover',true,
false); arguments[0].dispatchEvent(evObj);} else if(document.createEventObject)
{ arguments[0].fireEvent('onmouseover');}";
((JavascriptExecutor) driver).executeScript(mouseOverScript,ele);
}
}
OUTPUT:
text is: Use at least 8
characters. Don’t use a password from another site, or something too obvious
like your pet’s name. Why?
Both Actual and Expected values are Equal
Nice site....Please refer this site also Our vision success!Training are focused on perfect improvement of technical skills for Freshers and working professional. Our Training classes are sure to help the trainee with COMPLETE PRACTICAL TRAINING and Real time methodologies
ReplyDeleteDot Net coaching Institute in Chennai
Selenium Training Institute in Chennai
Software Testing Training Institute in Chennai | Testing Courses in Chennai
Java Training Institute in Chennai | Core Java Training in Chennai | Java Course and Certification
PHP Course in Chennai
I just want to offer you a big thumbs up for your great info you have right here on this post. I'll be coming back to your web site for more soon.Keep blogging.
ReplyDeleteSelenium training in Bangalore
Excellent post with lots of information about Selenium testing Technology.
ReplyDeleteSelenium Training in Chennai
I really enjoy the blog.Much thanks again. Really Great. selenium online training
ReplyDeleteExcellent & so informative Thanks for the info and knowledge share :)
ReplyDeleteVery interesting blog.Selenium testing important in IT industry. Many blogs I see these days do not really provide anything that attracts others, but believe me the way you interact is literally awesome.You can also check my articles as well.
ReplyDeleteDevOps Training in Chennai
DevOps Online Training in Chennai
DevOps Training in Bangalore
DevOps Training in Hyderabad
DevOps Training in Coimbatore
DevOps Training
DevOps Online Training
Amazing knowledge and I like to share this kind of information with my friends and hope they like it .Thanks for the writer to share the knowledge with us through this blog.keep sharing more blogs like this.
ReplyDeleteIELTS Coaching in chennai
German Classes in Chennai
GRE Coaching Classes in Chennai
TOEFL Coaching in Chennai
spoken english classes in chennai | Communication training
Thank you for the information. It was helpful.keep up!!
ReplyDeleteJava training in Chennai
Java Online training in Chennai
Java Course in Chennai
Best JAVA Training Institutes in Chennai
Java training in Bangalore
Java training in Hyderabad
Java Training in Coimbatore
Java Training
Java Online Training
Thank you for the information. It is very useful and informative
ReplyDeleteangular js course in chennai
angular course in chennai
angular js online course in chennai
angular js course in bangalore
angular js course in hyderabad
angular js course in coimbatore
angular js course
angular js online course
I just want to offer you a big thumbs up for your great info you have right here on this post. I'll be coming back to your web site for more soon.Keep blogging.
ReplyDeleteAWS Course in Chennai
AWS Course in Bangalore
AWS Course in Hyderabad
AWS Course in Coimbatore
AWS Course
AWS Certification Course
AWS Certification Training
AWS Online Training
AWS Training
Amazing knowledge and I like to share this kind of information with my friends and hope they like it.
ReplyDeleteacte chennai
acte complaints
acte reviews
acte trainer complaints
acte trainer reviews
acte velachery reviews complaints
acte tambaram reviews complaints
acte anna nagar reviews complaints
acte porur reviews complaints
acte omr reviews complaints
I have read your blog it is very helpful for us. I couldn't find any knowledge on this matter prior to. I would like to thanks for sharing this article here. please Do keep sharing more blogs like this.
ReplyDeletepython training in bangalore
python training in hyderabad
python online training
python training
python flask training
python flask online training
python training in coimbatore
Wind Turbine Technicians. According to the BLS, wind turbine technician is the fastest-growing occupation in the U.S. Plus, working on wind turbines means you're contributing to an important source of green energy.thanks lot!!!
ReplyDeleteAndroid Training in Chennai
Android Online Training in Chennai
Android Training in Bangalore
Android Training in Hyderabad
Android Training in Coimbatore
Android Training
Android Online Training
Thanks for sharing this blog its very informative and useful for us.
ReplyDeleteCyber Security Training Course in Chennai | Certification | Cyber Security Online Training Course | Ethical Hacking Training Course in Chennai | Certification | Ethical Hacking Online Training Course | CCNA Training Course in Chennai | Certification | CCNA Online Training Course | RPA Robotic Process Automation Training Course in Chennai | Certification | RPA Training Course Chennai | SEO Training in Chennai | Certification | SEO Online Training Course
Thanks for sharing your innovative ideas to our vision. I have read your blog and I gathered some new information through your blog. Your blog is really very informative and unique. Keep posting like this. Awaiting for your further update.
ReplyDeleteDigital Marketing Training in Chennai
Digital Marketing Course in Chennai
selenium online trainings from India
ReplyDeleteGood Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
ReplyDeleteSelenium Certification Training in Electronic City