Tuesday, October 30, 2018
Elasticsearch: Starting Over
I haven't worked with Elasticsearch in a couple of years. I remember using this on a project that I was on a few years back. But, now I'm on another project that uses this tool. So I need to re-learn and learn all the new things with Elasticsearch. But, this time, I'm documenting my learning so I can easily remember (if I forget this time around).
Labels:
elasticsearch,
indexing,
learn,
search,
search engine,
seo
Selenium Fireforx - Test with clearing browser Cookies
Today, I need to add a specific test that only works when the Cookie is cleared from the browser. This was much simpler than expected. Why reinvent the wheel?
See details @ https://stackoverflow.com/questions/35403614/clear-browser-cookies-with-selenium-webdriver-java-bindings
See details @ https://stackoverflow.com/questions/35403614/clear-browser-cookies-with-selenium-webdriver-java-bindings
Friday, October 26, 2018
Selenium Testing - My References & Bookmarks
Quickly Learning to be a Software Engineer in Test (SET)
In short, because I am learning so much and coding/testing so fast, I can't remember everything and I need to remember specific things fast and with order. So, this is my page to help me remember these important things for being a Software Engineer in Test (SET) or in simpler titles known as Test Engineer.Online References
Selenium - FindElement(By <CSS Selectors>)
Useful Background Information
Online Tools
Load Testing Tools
Online Blogs
Labels:
test,
test automation,
test engineer
Thursday, October 25, 2018
Journey into SET: Part 3 - Follow Test Engineers
In this part of the journey, it's important to learn from other Testers (or SETs or Test Engineers). Yes, it's important to learn from Developers as well, but sometimes we forget the benefit of learning from other Testers. After all, we discover different things yet having the same overall mission: test the crap out of software! Well, not for any old reason, but with the goal of producing a quality product useful to our users and ourselves.
Anyhow, here are some Testers in the industry that I'm following.
Anyhow, here are some Testers in the industry that I'm following.
Test Engineers
Test Tools
Debugging Errors - Trailing Whitespace in Properties file
Problem
Well, I know this seems minor, but when you're using Properties file to maintain a list of usernames/passwords for a Test Script that tests logging in as each user (because a specific user role is associated to these demo users), then this is a good way to maintain testing of the application's login.So, long story short, one of users would crash the browser by hanging up the login page when attempting to login.
Solution
Long story short, I had one whitespace char trailing the username. So instead of the username being "user1", it was "user1 ". This whitespace char was not caught and handled well in the application which is now fixed, but this took a lot of time to debug. Unnecessarily.Be sure that your Properties file has the property value as expected. Use a text editor displaying all characters in file, if need be.
Cheerios!
Wednesday, October 24, 2018
Killing Application Processes in Linux CentOS
I can't believe I have to write a post about this, but my Selenium test is hanging in the Firefox browser. I don't have time to figure out if it's my Eclipse IDE causing the Java Runtime issue or my Maven (with I doubt although this is how I launch the test to run) or Selenium driver that I'm using in Maven.
But, I got tired of searching online for the same commands because I can't remember all these Linux commands. I just don't work in Linux Terminal enough to remember all this in addition to what I'm actually coding.
Here's the article I reference (and avoid rebooting my machine):
https://www.makeuseof.com/tag/6-different-ways-to-end-unresponsive-programs-in-linux/
Here's the command I typically use:
$ ps aux | grep firefox
$ kill <processID>
Go process hangups! (Really though, why are we still having these silly issues in 2018?)
But, I got tired of searching online for the same commands because I can't remember all these Linux commands. I just don't work in Linux Terminal enough to remember all this in addition to what I'm actually coding.
Here's the article I reference (and avoid rebooting my machine):
https://www.makeuseof.com/tag/6-different-ways-to-end-unresponsive-programs-in-linux/
Here's the command I typically use:
$ ps aux | grep firefox
$ kill <processID>
Go process hangups! (Really though, why are we still having these silly issues in 2018?)
Tuesday, October 23, 2018
Selenium Firefox - Test dynamic webelement with waits
Problem
The problem I am having today is that my test that was working is now having issues related to browser performance. I am testing for an element to display in two tabs. The first tab opens and the element is captured. Next, the second tab opens to the same exact page, but Selenium can't find the element to capture before closing the browser.I thought my implicit wait on the driver would suffice. It seemed to yesterday anyhow. So, now I am researching "waits".
https://www.seleniumhq.org/docs/04_webdriver_advanced.jsp
I didn't seen enough information on the main website for Java. So, I googled online for more information. Perhaps someone else has a cleaner solution? During my search, I noticed that there are two explicit waits: WebDriverWait and FluentWait. But, what is the difference?
FluentWait vs WebDriverWait
https://www.softwaretestingmaterial.com/webdriverwait-selenium-webdriverhttps://www.softwaretestingmaterial.com/selenium-fluentwait/
https://stackoverflow.com/questions/40753321/fluent-wait-vs-webdriver-wait
Essentially, the difference is FluentWait offers more handling of exceptions in case the Wait doesn't find the element, etc. This is my understanding so far. Thus, I'll continue with WebDriverWait which auto ignores exceptions (like NoSuchElementException).
This is all good to know, but useless without knowing the impact of the class ExpectedConditions. This class "ExpectedConditions" has some key methods that we need to know when looking for a specific element or element attribute or element value.
https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/support/ui/ExpectedConditions.html
Well, there are a lot. Unfortunately, there aren't examples for each of these methods giving a descent explanation between the methods that appear similar.
Moving forward, this is an interesting, old article (posted in 2014). The author is first looking for the element and then looking for the text inside the element. Is this really necessary instead of simply looking for the text inside the element? Isn't there a wait on the element being completely rendered with text already? I don't know, but this would be to discover and understand.
http://www.software-testing-tutorials-automation.com/2014/01/webdriver-wait-for-text-to-be-present.html
Solution
Before digging into the details to understand, I discovered that this works. Here's my code which resolved my issue. Notice, this is a common method used by multiple tests.
public static Boolean isAgreementDisplayed(Webdriver driver, Integer waitSeconds) {
WebDriverWait wait = new WebDriverWait(drive, waitSeconds);
wait.until(ExpectedConditions.presenceOfElementLocated(By.className("modal-title")));
boolean modalTitleExists = wait.until(
ExpectedConditions.textToBePresentInElementLocated(By.className("modal-title"), "User Agreement"));
return modalTitleExists;
}
Now, if I remove the first "wait" call, will my code still work? Surprisingly, or maybe not surprisingly, it does work. So, now my code looks like this (although I know I can shorten it more) and my test waits for my dynamic webelement to display and check its text before completing assertion.
Cheers!
public static Boolean isAgreementDisplayed(Webdriver driver, Integer waitSeconds) {
WebDriverWait wait = new WebDriverWait(drive, waitSeconds);
boolean modalTitleExists = wait.until(
ExpectedConditions.textToBePresentInElementLocated(By.className("modal-title"), "User Agreement"));
return modalTitleExists;
}
Cheers!
Subscribe to:
Posts (Atom)