Thursday, September 22, 2022

WebDriver: Tracing the Interface WebDriver - Part 2

 

In the previous post of this WebDriver series, I shared a gist about what WebDriver does and how.  In this blog post as Part 2 of this series, I'm sharing a bit more details on WebDriver and RemoteWebDriver.  

From there, we will see how AppiumDriver is related to WebDriver -- which extends the interface SearchContext.

This blog post is written as part of 21Days21Tips from The Test Chat.  The tip shared in this post is to know more about WebDriver internals and how it associates with RemoteWebDriver and AppiumDriver.

This should help in understanding the Selenium APIs better and from where it comes.  This helps in having a better mental model of the Selenium WebDriver and how we want to structure the instructions in the tests and utilities we write


SearchContext and WebDriver



Picture: Representation of SearchContext and hierarchy of WebDriver


  • The SearchContext is the parent interface in the WebDriver hierarchy
    • The subinterfaces of SearchContext are
      • WebDriver
      • WebElement
  • This SearchContext defines two methods
    • findElement(By by)
      • Modifier and Type is: WebElement
      • It finds the first WebElement using the given method
    • findElements(By by)
      • Modifier and Type is: java.util.List<WebElement>
      • It finds all elements within the current context using the given mechanism
        • NoteI'm referring to Java APIs of Selenium in this blog post
        • More details of this can be found here.

Note: Selenium's Ruby client describes the Interface SearchContext as this.  


The WebDriver provides the below methods:
  • close()
  • findElement(By by)
  • findElements(By by)
  • get(java.lang.String url)
  • getCurrentUrl()
  • getPageSource()
  • getTitle()
  • getWindowHandle()
  • getWindowHandles()
  • manage()
  • navigate()
  • quit()
  • switchTo()

More details of these methods can be found here.


RemoteWebDriver and AppiumDriver


Further, we see the class RemoteWebDriver implements the interface WebDriver.  Today, the WebDriver and RemoteWebDriver communicate using standard W3C specifications.

That way, all the modern browser which adheres to W3C specification should not have (much) trouble when using WebDriver and RemoteWebDriver to mimic the user action on them.  We see the ChromiumDriver(), ChromeDriver(), FirefoxDriver(), Edgedriver, SafariDriver(), and OperaDriver() extending the RemoteWebDriver.

This hints us to know and learn:
  1. Why do we initiate the WebDriver for first
  2. And, then we instantiate the browser's driver
  3. Later how we use WebDriver's instantiation to drive action (mimic the user action) on the browser using the respective browser's driver
When we want to automate using Selenium Grid, we make use of RemoteWebDriver to drive the action between the client and server.

The class AppiumDriver extends the WebElement and RemoteWebDriver from the project Selenium.  And further, it has its own methods to interact with the mobile elements.  More details about the Java Client of AppiumDriver can be found here.

The subclasses of AppiumDrivers are:

  • AndroidDriver
  • iOSDriver
  • WindowsDriver


21 Days 21 Tips -- #day17

Here are my pointers to fellow test engineers

  1. Interface SearchContext is top in the hierarchy of the WebDriver interface
  2. Interface SearchContext defines
    • Should I want to search for the element in the whole page
      • using WebDriver object
    • Or, should I search within a containing element
      • using WebElement object
        • We can notice methods returning the type WebElement
  3. RemoteWebDriver implements the interface WebDriver
  4. The modern browsers drivers extends the class RemoteWebDriver
  5. AppiumDriver extends the class RemoteWebDriver and interface WebElement
For more understanding of the SearchContext and WebDriver, refer to below git repository of SeleniumHQ:

The below understanding should give a mental model of how the call happens in Selenium's library:
  • WebDriver and browser's driver instantiation
  • The order in which it is instantiated and used in programming to automate actions on the  browser

If noticed, the automation we do is more of programming and not of Selenium's library.  We extend and implement the Selenium library in our programming to mimic the action on the browsers and mobile apps.


Tuesday, September 13, 2022

A Direction Sign for Beginners and Everyone to Start and Grow in Software Testing

 

I'm volunteering for the Agile Testing Alliance (ATA) for this year 2022.  This 10th September 2022, we had an ATA Round Table Talk 2 on account of International Testers Day.  We planned two events on this day -- QuizATAhon-1 and Ask Me Anything (AMA) with ATA volunteers.

One of the questions that we volunteers got from the community is:

"Best advice for beginners who wants to start there career in the testing field as per there experience level"

I shared my thoughts on this question in the AMA session.  I have a strong intuitive feeling that this will be the question of the interns, freshers, and also of experienced test engineers.  Hence, I want to write it as a blog post, so that it can be referred to as one of the directional heuristics.


This is Not an Advice

What I'm sharing in this post it is not advice.  It is information. You can use this information to advise yourself on what you should be doing to grow consistently in the practice of Software Testing and testing job.  As said, it is a directional heuristic that you can use.

This information will make sense to every one of us irrespective of experience in the industry with software testing as a career and practice.  There is no best advice.  I see, advice is information or carries a piece of information that can show us a direction.  And, the advice is a heuristic!


Direction Sign To Be a Skilled Tester

This will be super useful to you if you actually make use of it to your need and to the maximum possible extent that you can.

  1. Find your Software Testing Community
    • You might find the community quicker than finding the people, books, and syllabus of Software Testing
      • If you don't read Software Testing and Programming resources, someone in the community might be reading it
      • You can use their learning for your growth
    • Look out for the Software Testing Communities in your place (city or country)
    • Just do not look at one testing community; find more than one active communities
      • Collaborate with the communities
      • Interact with fellow Test Engineers in the community
      • Start contributing to the communities in the possible ways you can
    • Note that, the groups on Social Media will not make it a community
      • People come together in a community
      • Events, Meetups, Conferences, Discussions and much more will happen in the communities
    • Today we can associate with Software Testing Communities which are in other countries
      • Could be this community will have one of its chapters in your city or country
    • Find the Software Testing communities
  2. Mindset - Do not get easily influenced
    • You are bound to get influenced and follow easily
      • when you look into the community and the people in the community
        • with their works, writing, accomplishments, social presence, and identity
      • when your fellow peers in college or the workplace talk about testing to you in anyways and in any dimensions
        • It is their opinion
        • It is their understanding
        • It is their assumptions
        • It is their mindset
      • and, with what you read or watch about testing posted on social spaces
    • Have the mind and thought that questions; try to seek what makes sense rationally to you
      • Be practical and experimental
      • Do not attach your past and present experience's emotion to others' opinions
        • You evaluate it
        • Pick what makes sense to you and to your context
    • Do not be a mind of other Test Engineer or practitioner
      • Have our own voice and identity
      • Express your opinion while you respect the work and opinion of other Test Engineers and practitioners
      • Develop your working style, learning style, and problem-solving style
        • But do not stop observing others and how they are doing it!
    • Question!
      • It is about being included than being influenced
      • Do not stop questioning
      • Talk, and talk with respect!
    • A test is a question asked to learn what it is and to understand what actually it is
      • It needs a mindset
      • A mindset not to get easily influenced and accept an opinion or a thought
    • Note: Do not be influenced by this blog of me; just read it as a heuristic
      • You build your approach using this heuristic only if it helps you
  3. Knowing the chaos around Software Testing is very important
    • Everyone knows Software Testing and everyone believes to have an idea of what it is
      • This is the state of mind in the college that teaches computers and programming
        • This is the state of mind in the software industry
      • Chaos starts right from the syllabus, textbooks, and reference books, and with you
    • Here are some chaos and myths existing for 20+ years and they will exist in the coming years
      • Software Tester has no bright career as Software Testing is not technical
      • End of Software Testing is coming soon
      • Software Testing has seen its end
      • No need of knowing the programming
        • It is a necessity in today's Software Development context
      • It is an easy job
        • Is it so?
        • Try finding at least 3 business stopping risks and problems in the system every day
          • If you do this consistently, label it as an easy job
          • Let your business stakeholder acknowledge the findings of your testing as a business stopping risks and problems
      • No good money earned when compared to a programmer
      • No career in Software Testing as we grow with our experience in the industry
      • To be a Software Tester one need not be technical
      • It is a Women's job
        • Yes, that is how it was projected and was said
          • I'm saying this from my experience in India
            • I'm not aware of how it was or it is in other countries
        • 2014 and onwards, I have not heard this statement
        • Happy, that we don't hear this today
          • Thanks to SDET and SET roles
            • At least, this removed the gender bias is what I see
            • Today both women and men work in the role of SDETs
              • I worked with women SDETs and I did learn from them; I say this is in pride
          • I'm happy that women are taken out of this framing today
            • I'm very happy!
            • We don't have to bring gender discrimination in Software Testing career and jobs anymore
            • I see, there is no job that women cannot do today in the technology space
              • This is an empowerment of women
              • Women are equally skilled and work to upskill
          • We have skilled women technologists, CTOs, VP Engineering, Architects, Test Architects, SDETs, & Test Engineers
          • I'm happy that I have worked with technically skilled women and I reported to a few of them
          • Ah! I should stop calling men and women here; it is we Test Engineers
    • Do not panic with the chaos that is created frequently and consistently
      • Talk to your community
  4. Find your Mentors
    • I said mentors and not a mentor
      • Have more than one mentor
      • Know how to work and practice while you have more than one mentors
      • Respect your mentors by giving the credits and with your gratitude
    • Find your mentors in the workplace and in the community
    • Good if your mentors have the contrasting thought process and ideologies
      • Pick from both sides
      • Know what both sides advocate and practices
      • Apply the appropriate one to your work when the context demands it
    • Do not be the mouthpiece of your mentor
    • Do not be the mind copy or replica of your mentor
    • Do not imitate your mentor
    • Seek your mentor's assistance in you being you
      • Seek help in growing with your identity and voice
      • Have a voice and your identity
  5. Communicate with your Software Testing Community
    • When you talk to the community, you will know
      • where you are
      • where is Software Testing
      • the challenges your fellow testers in the community are having
      • how the challenges and problems are being solved
    • It will set you a tempo with an attitude if you talk and share your learning
    • In simple, just read or listen to the problems the testers share everyday
      • This is awareness!
      • At least, it opens to the awareness of technology, tech stacks, problems, solutions, industry, people, and more
    • Attend the meetups
      • Small crowd and high interaction with networking
      • High exchange of learning and experiences
  6. Be the Technical Mind
    • We Test Engineers are said to think like a user
      • Good!
      • This is an empathy mindset that is being cultivated in us for the users who use the solution we are building
      • But this empathy is alone enough today? No!
    • Empathy with technical skills will be much value adding
      • And it is today's need
    • When I say technical, it is not just programming
      • Programming is one small aspect of being technical
    • Let your technical journey start from learning:
      • How this works and what makes it work
      • Know the technology layers internally and externally when you learn how it works or when it does not work
      • Start here! And expand your technical capability dimensions
    • Today, we are said and expected to think like an engineer
      • An engineer who understands the user
      • An engineer who understands the business
      • An engineer who understands the investor
      • An engineer who understands the management and managers
      • An engineer who understands all this can change at any time
      • An engineer who can work, scale and deliver in a startup mindset and environment
  7. Seek and Share Awareness
    • What sets back we Test Engineers is the lack of awareness before lack of attempts to practice
    • We don't work, collaborate and associate to be aware of
    • We are not aware of -- what to be aware of
      • This includes me as well
      • I consistently keep trying to be aware
    • Do not just attend  and be part of the Software Testing community
      • Attend the community of programmers, DevOps, products, businesses, startups, enterprise
      • You will see the direction sign -- which happens to be a heuristic
  8. Know what is your Software Testing
    • Everyone has their understanding of Software Testing
    • Engineering Managers and Director of Engineering with whom I worked had their own understanding of Software Testing
      • No one was similar nor did match anywhere
      • All have their version of testing in their work
    • Know what is Software Testing you want to practice
    • Software Testing is contextual
      • Tailor and deliver Software Testing to what is expected at your workplace
      • While you do that, try educating your fellow Test Engineers
        • That's the seeding
        • This is the place where we can seed and harvest for a better tomorrow in Software Testing and for our growth
  9. Practice your Software Testing in all dimensions
    • Software Testing is with people, software, hardware, and more
    • When we are dealing with Software we cannot be away from programming
    • Programming gives a different order to our testing
      • Practice programming
      • Embrace it
      • Shell out the fear of programming
      • Start small; more importantly start and continue
        • To keep going, find one tester in the community who wants to do it
        • Go to your mentors and follow up with your accomplishments, setbacks, challenges, and problems
        • Get unblocked; make progress; learn, implement and share
    • Do not run away from the practice of automation
      • It is a necessity for today's Software Development & Engineering
    • Find all possible dimensions you can
  10. Build your portfolio
    • Explore how to build your portfolio in Software Testing
    • Ask community
      • We have several portfolios to refer to in the community
    • Build it and continue improvising it with the time and context
  11. Solve the Software Testing problems
    • Before solving at least be aware of the problems
    • Community is one place where you can hear the problems and challenges
    • Contribute to the solution and solving
      • This helps you a lot as a practicing Test Engineer
    • Problems come in flavors and contexts
      • Testing, Automation, DevOps, Product, Requirement, Delivery, and more
        • Have yours hands-on on all these verticals to help and scale your testing and automation
    • This will make you talk and help you grow with experience and learning
  12. Tune up yourself with Business, Political, and Management skills
    • Not all problems can be solved with a technical mindset and skills
    • It needs the skill of political and management orientation
      • Do good and be good
      • Work on how you communicate; it is important
    • Know how the business decisions are made
    • Know how business decisions influence technology, engineering, and anything
      • The business decision need not be based on logical and technical analysis
  13. Beat your EGO and respect your self-respect with dignity for Software Testing
    • Ego has killed a lot of us from talking and growing
    • Ego has made many managers lose their engineers
    • Ego had made many testers lose what their managers could offer to learn and grow
    • Software Testing has its touch points in every vertical of Software Development
      • Programming
      • DevOps
      • Product Management
      • Solutions
      • and, what else?
    • Testing is done in all these verticals
      • Ego can set us back and block from what we can make for our benefit and contribute to the organization and business
    • Managing the ego is a skill
      • While managing ego, balancing one's self-respect is a challenge
        • Know what is the objective and what you make out of it for your growth
      • While doing this keep the dignity of Software Testing and team morale high along with your self-respect
      • Talk to your mentors!
    • Yes, talk to your mentors
      • Mentors might be handling ego, self-respect, and dignity of their work and practice
      • Your mentors can tell you the ways to do it
    • Take care of your Mental Health and help others too
      • Physical health is also important


This information should hint you with the direction of practice, growth, and excellence as a Software Testing practitioner.  I'm here to connect with you anytime and talk more and take it forward.


Monday, September 12, 2022

Testability: More About it from the Programming Literature

 

My friend Parimala Hariprasad gifted me the book Essential Skills for The Agile Developer, authored by Alan Shalloway, Scott Bain, Ken Pugh, and Amir Kolsky.  Thank you, Parimala, for gifting this book.  I'm experiencing the value of this book and using it.

In this post, I'm sharing the content shared in Chapter 3 of this book. It is about Testability and how it improves the code quality.  


Why this Blog Post?

I continue to read Software Testing literature.  I understand the below as one of the primary key skills for a Software Test Engineer practice:

  • Identifying the Testability attribute in the system
  • Mapping and classifying how the available Testability attribute can be used in Tests
  • Asking for the Testability attribute
With that, I understand "how easy it is to test by a test engineer in a given context" as Testability.  If noticed, this is from Software Testing literature.  And, I see it has these three elements which tell the prominence of each:
  • How easy it is to test?
    • what factors make it easy to test?
    • how does it make it easier?
    • how does it bring the deterministic character?
    • how can I isolate the observations with my analysis with the help of deterministic character and aid added?
  • By a Test Engineer's
    • awareness, experience, learning, applying the skills, and more
  • In a given context
    • time, people, environment, availability, and more
If any of these three elements has trouble, it has its effects on the test and testing.  If you ask what effects, I don't know.  If I pick from my case to share one of the effects, I say, I was not very sure what was happening though the product looked to do what is expected.  But will it continue to do what is expected to do and in what all ways? I had no answer for in what all ways and in what contexts. This is one such case of how the absence or not using the Testability can influence the tester to be unsure about the learning made with help of a test.

The book I mentioned here gives another perspective from the Computer Programming literature.  It talks at the fundamental level and I see this is important to understand for we Test Engineers.  Soon in the coming days, we Test Engineers will be working and testing in these layers of product development. 

In the next section, I will share the lines from the book as is in italics and blue font color word.  The credits are to the authors of this book. I'm taking the text as it is from this book.  And, I will share my interpretation for the same and see the relativity of Computer Programming and Software Testing literature.  

Note: The credit is to James Bach for the Testability definition used above.  I added "the tester and context" to it as these two influence the Testability and outcome of using the Testability to a greater extent.


Testability and Code Quality

The authors of the book say, "testability is highly correlated to the code qualities we want to manifest, in particular, loose coupling, strong cohesion, and no redundancy."  Further, they illustrate how one remarks at the start of testing one's code by saying the below:

I can't test this code; it does too many things that are so interwined -- weak cohesion

I can't test this code without access to dozens of other things -- excessive cohesion

I can't test this code; it's been copied all over the place, and my tests will have to be duplicated over and over again -- redundancy

I can't test this code; there are too many ways for external objects to change its internal state -- lack of encapsulation


Then I read this line from the authors, "Gee, I wish they had thought of how this code was going to be tested while they were writing it!".  That's a question that every one of us has to ask ourselves for the work we deliver and not just for the programming.  

Alan Shalloway says he is kind of slow sometimes because it took him some time to realize this -- I should consider how my code is going to be tested before writing it! 

Testability is related to loose coupling, strong cohesion, no redundancy, and proper encapsulation.  Another way to say this is:

  • the tighter your coupling, the weaker your cohesion; 
  • the more your redundancy and the weaker your encapsulation, the harder it will be to test your code
Therefore, making your code easier to test will result in the loose coupling, strong cohesion, less redundancy, and better encapsulation.  This leads to a new principle -- Considering how to test your code before you write it is a kind of design.

Since testability results in so many good code qualities and since it is done before you write your code, it is a very highly leveraged action.  That is, a little work goes a long way; it is a great trim tab.


I and Testability


I try to understand and learn about Testability every day in my practice.  When I started my career 15 years back, I learned from my network, that one of our fellow testers in the community that is Meeta Prakash did her Ph.D. in Testability.  I wanted and still want to read the thesis of Meeta Prakash.  I hope she will find it and give me soon, one day.  In those days, I referred to the slides of James Bach on RST; that legacy slides that had contents filled with blue color. 

From there, I tried looking into the testability in what I test and what programmers deliver to me.  When I worked with Moolya in 2012, I realized from my practice -- context and the skill sets of a tester matter to make use of the available testability and to identify if it is present or not, and to what extent. I added this to the definition of James Bach and I shared the same with my fellow testers with whom I was mentoring and working together.


Relating the Literature and Interpretation


When the programming is talking about testability, I see it is talking about:
  • internal aspects of how it is programmed and to test the same easily in isolation, and in integration for the context while being deterministic
The words used to express in programming literature are more programming oriented.  Whereas, what we see in the Software Testing literature, it is more of a common man's words.  But, what both means is the same and the difference between them is to which layer and aspect they are referring and how, and why.

The Weak Cohesion
  • It will be an obvious experience to a tester when it is difficult to speculate and pull a particular observation with more information for a feature or a user flow
    • For example, if the Refresh Token is used along with Auth Token everywhere, then it will be tough to isolate when Refresh Token is used and when the Auth Token is used
I feel the same when wanting to test a piece of code in isolation from other code.  I have experienced this when testing one aspect of utility or a complete utility in isolation from the rest of the automation code.


The Excessive Cohesion
  • I could not test the mobile apps as I needed data
  • Certain data came from a portal that is also under development and depends on APIs to work
  • APIs would be under development till the last day of release and did not deliver the endpoints to the portal and mobile apps team
So how could the test team create data to test for mobile apps, web portal, and for APIs themselves?  If you see this is excessive cohesion at the product development level.


The Redundancy
  • In one project, I had to login each time to see the status of a session
    • All tests were programmed in a way that I should login each time
  • The test team used the login function in every test and it was duplicated
  • When signed in, the Auth token got changed which lead to difficulty in debugging and isolating the problem
This complicated the test code and also messed up debugging.  The tests could not be deterministic here.

I see a static Auth token or one-time login and using the same Auth token in all other tests in the suite could have helped to debug the problem and where it occurred.


The Lack of Encapsulation
  • My team had a tough time when started to use an existing automation
  • It had public access modifier for all methods in all packages
    • The team picked up and authored more tests that changed the data and states
  • This led to any object of a method to modify the data or state; it was not supposed to be modified at all
  • The debugging led us here and it was not a problem with the product
    • It was the problem with the product's automation code and how the tests changed data and state;  it was in turn used in other tests
This led to much more chaos as the automation and testing environment were the same.  The invalid bugs, meetings that got scheduled to discuss and time went into the meeting that ended with no use, and a couple of releases came into a decision should we deploy or not, and more.



Continuing the Unlearning and Learning of Testability


If you see, Testability has got multi-dimensions in the dynamics of software development.  Testability is not just about Programming and Testing.  It can be from the environment, project, people, what we understand and how we use it further in work, and the business itself.

I continue to unlearn and learn testability every day as I practice testing and automation.