Selenium WebDriver- Debugging Code (Breakpoints) - Java Debugging with Eclipse
Most of us interested to know, how the code is getting executed. Some times, even if we write the code with out having any syntax errors also during execution we face issues which requires debugging of the code.
As Web-driver script executes fast, if we want to execute the Web-driver code line-by-line and verify the Output can be achieved using the Debug Mode in Eclipse.
Lets start. I have written a very simple example in Selenium Webdriver to retrieve the text in Facebook as highlighted in the below image.
Facebook.java
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Facebook {
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
driver.get("https://www.Facebook.com");
String actual = driver.findElement(By.xpath("//span[text()=' See photos and updates ']")).getText();
System.out.println(actual);
String expected = " See photos and updates";
if(actual.equals(expected))
{
System.out.println("Actual is equal to Expected TC - Pass");
}
else
System.out.println("Actual is not equal to Expected TC - Fail");
}
}
There are no syntax errors in the code. Please try to execute the code as shown below:
Output:
Actual is not equal to Expected TC - Fail
In the above scenario the TC should pass. But we are getting response as TC-Fail.
So, how do we identify the issue. What is the reason for failure.
We have to use Debug mode to identify the root-cause for this issue.
Debug - Step1- Insert BreakPoint
Right-click at the line number 10 and select the first option - 'Toggle Breakpoint'. It means we are inserting the Breakpoint, so we can verify the values in the variable at run time.
In our case we can verify the value stored in the 'actual'.
Step2-Run Facebook.java in Debug mode
Step3- Debug Perspective opens as shown below
Select the checkbox-'Remember by decision' and click on 'Yes' button.
The Debug perspective opens, it has three tabs Variables,Breakpoints,Expressions.
Out of three tabs- Expressions tab is required to view the values at run-time.In Debug perspective if you are unable to identify this tab. You to follow the steps as show below:
Navigate to Expression tab and click on 'Add new expression' enter 'actual' as shown below:
Click on Step-Over to move to next step. Verify the 'actual' value in the Expression tab.Also add few more expressions as shown below:
Actual String length-> actual.length()
Expected String length()->expected.length()
Click on Step-Over to move to next step. Verify all the values as shown below:
Conclusion
The length of expected String is 23.
The length of actual String is 22.
So there is an issue in expected string. In the program we provided the String expected =" See photos and updates";
There is an unnecessary space added in the string. It should be changed to String expected ="See photos and updates";
by removing the unwanted spaces.
Once identify the issue click on terminate button as shown below.
Change the Perspective from Debug Mode to Java Mode.
Remove all the breakpoints.
28 comments:
This blog will get more thoughts. This is exceptionally useful for Software Testing students. Much thanks to you for sharing this great site.
Selenium Training | Selenium Classes in Chennai | Best Selenium Training in Chennai| Selenium Testing Training in Chennai
Excellent blog, I wish to share your post with my folks circle. It’s really helped me a lot, so keep sharing post like this
python training in tambaram
python training in annanagar
python training in velachery
All the points you described so beautiful. Every time i read your i blog and i am so surprised that how you can write so well.
Blueprism training in marathahalli
Blueprism training in btm
I read this post two times, I like it so much, please try to keep posting & Let me introduce other material that may be good for our community.
Data Science training in Chennai
Data science training in bangalore
Data science online training
Data science training in pune
Thank you for taking the time to provide us with your valuable information. We strive to provide our candidates with excellent care and we take your comments to heart.As always, we appreciate your confidence and trust in us
java training in omr | oracle training in chennai
java training in annanagar | java training in chennai
An interesting topic with great examples, keep updating your knowledge with us.
Selenium training in chennai
Selenium training institute in Chennai
iOS Course Chennai
Digital Marketing Course
Digital Marketing Course in Chennai
Great blog with lots of examples. Update more like this.
Angularjs course in Chennai
Angularjs Training in Chennai
Angularjs Training
AWS course in Chennai
DevOps Certification Chennai
Robotics Process Automation Training in Chennai
Thank you for sharing this post.
Guest posting sites
Technology
I’m bookmarking and will be tweeting this to my followers! Wonderful blog and amazing design and style.
nebosh course in chennai
This article is very effective. Your content is very massive and it's easily understand to me. Thanks for your depth information.
Ethical Hacking Course in Bangalore
Hacking Course in Bangalore
Certified Ethical Hacking Course in Bangalore
Ethical Hacking Training in Annanagar
Ethical Hacking Course in Adyar
Ethical Hacking Course in Tnagar
Ethical Hacking Training in Nungambakkam
I wondered upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I’ll be subscribing to your feed and I hope you post again soon.
RPA courses in Chennai
Robotic Process Automation Training
RPA course
Robotic Process Automation Courses
learn Robotic Process Automation
RPA Training Course
Useful blog, This is what I have looked for. Share more like this.
Data Science Course in Chennai
Data Science Training in Chennai
UiPath Training in Chennai
Blue Prism Training in Chennai
DevOps Training in Chennai
Amazing Post. The content is very interesting. Waiting for your future updates.
Xamarin Training in Chennai
Xamarin Course in Chennai
Xamarin Training
Xamarin Course
Primavera Training in Chennai
Primavera Course in Chennai
IELTS coaching in Chennai
IELTS Training in Chennai
Very Clear Explanation. Thank you to share this
Regards,
Data Science Course In Chennai
Data Science Course Training
Data Science Training in Chennai
Data Science Certification Course
Data Science Certification Training
Data Science Training Institute
Those guidelines additionally worked to become a good way to recognize that other people online have the identical fervor like mine to grasp great deal more around this condition.
fire and safety course in chennai
its a good post and keep posting good article.its very interesting to read.
Data Science Training in Chennai
Awesome..You have clearly explained …Its very useful for me to know about new things..Keep on blogging..
Microsoft Azure online training
Selenium online training
Java online training
Java Script online training
Share Point online training
https://opencvexamples.blogspot.com/p/learning-opencv-functions-step-by-step.html?showComment=1535611313888
Microsoft Azure online training
Selenium online training
Java online training
Java Script online training
Share Point online training
Great Applause. The content you shared is very inspirational. Thanks for Posting.
Blockchain certification
Blockchain course
Blockchain courses in Chennai
Blockchain Training Chennai
Blockchain Training in Anna Nagar
Blockchain Training in T Nagar
Blockchain Training in OMR
Blockchain Training in Porur
Nice blog,I understood the topic very clearly,And want to study more like this.Thanks for this blog, I'am very much delighted to say that this blog has helped me a lot in gain some extra knowledge.
Selenium Training in chennai | Selenium Training in anna nagar | Selenium Training in omr | Selenium Training in porur | Selenium Training in tambaram | Selenium Training in velachery
The Blog is really nice. every concept should be very neatly represented. easily able to understand the concept.
Data Science Training Course In Chennai | Data Science Training Course In Anna Nagar | Data Science Training Course In OMR | Data Science Training Course In Porur | Data Science Training Course In Tambaram | Data Science Training Course In Velachery
"Nice blog happy to see you are helping the people for better understanding.
Digital Marketing Training Course in Chennai | Digital Marketing Training Course in Anna Nagar | Digital Marketing Training Course in OMR | Digital Marketing Training Course in Porur | Digital Marketing Training Course in Tambaram | Digital Marketing Training Course in Velachery
"
This is an awesome blog. Really very informative and creative contents. This concept is a good way to enhance the knowledge. Thanks for sharing.
Oracle Training | Online Course | Certification in chennai | Oracle Training | Online Course | Certification in bangalore | Oracle Training | Online Course | Certification in hyderabad | Oracle Training | Online Course | Certification in pune | Oracle Training | Online Course | Certification in coimbatore
it is really amazing...thanks for sharing....provide more useful information...
Digital Marketing Training Course in Chennai | Digital Marketing Training Course in Anna Nagar | Digital Marketing Training Course in OMR | Digital Marketing Training Course in Porur | Digital Marketing Training Course in Tambaram | Digital Marketing Training Course in Velachery
This is quite educational arrange. It has famous breeding about what I rarity to vouch. Colossal proverb.
Android 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
I think this is a standout amongst the most critical data for me. What"s more, i"m happy perusing your article. Be that as it may, ought to comment on some broad things
data scientist course in hyderabad
Nice blog, thank for sharing with us.
Data Science Course with Placements in Hyderabad
This blog, in my opinion, is among the best because it has been quite beneficial to me. I appreciate you sharing this useful information.
IELTS Coaching in Ahmedabad
Post a Comment