Toptal is a marketplace for top Selenium developers, engineers, programmers, coders, architects, and consultants. 顶级公司和初创公司选择Toptal Selenium自由职业者来完成他们的关键任务软件项目.
Papuna is a highly skilled QA automation and DevOps engineer with experience in Linux system administration and network engineering. He has leadership experience in QA teams and skills for delivering high-quality end-to-end tests. Papuna使用微服务和无服务器架构设计和实现了可扩展的系统.
Deniz has over nine years of experience in software test automation, framework, and test architecture design. He led and mentored teams and created guidelines about testing. Deniz is an expert on Selenium, Cypress, Playwright, WebdriverIO, Protractor, and many other test automation technologies and programming languages. He communicates exceptionally well and has a keen eye for details. Deniz has been working remotely for the last couple of years, providing expert guidance across continents.
For the past seven years, Jovana has worked as a QA engineer collaborating with various QA teams and on complex functional testing (manual and automation) on multiple types of applications. She's passionate about bug hunts and is known as a hard-working team player who loves to learn. Jovana thrives under pressure and this can be seen in her history of successfully dealing with deadlines and product deliveries.
Enzo is an engineer with 18 years of experience in QA/QA automation, working with the latest technologies and highest industry quality standards and automating web UIs, Rest APIs, and back-end services. He's comfortable in startups and large companies, either as the first QA member or joining teams of all sizes. Enzo also has experience defining processes, procedures, and tools to achieve the best quality.
Andrej is a certified software engineer in test (QA) with more than 15 years of progressive experience in software testing methodologies, best practices in test automation, and a variety of test tools. He achieves project objectives through passion, commitment, and expertise. Andrej在具有多个集成点和紧迫截止日期的项目中具有复杂测试工作的实际经验.
Leonardo has over a decade of software testing experience in Agile testing, load testing, continuous delivery, and mostly testing automation. He’s capable of working with a wide variety of software quality tools and environments. Leonardo is certified in Tester Foundation Level and Tester Advanced Level and also has a technical license in software analysis/development and graduate studies in business management specialization.
Thiago is a QA engineer with 12+ years of experience who's proficient in functional and regression testing using C#/Java and Selenium for UI testing and RestSharp (C#)/RestAssured (Java) for API testing. He's worked with several application types, is able to build a strong background, and communicates well with both business and development ends of the team. His will to solve problems is one of the keys to his success.
United KingdomToptal Member Since October 24, 2019
Fayaz is a DevOps engineer and architect with experience in designing end-to-end solutions. He has extensive cloud and infrastructure expertise with multiple AWS, Azure, and Google Cloud certifications. He specializes in monitoring tools (ELK, Zabbix, and Prometheus) and automation with Python, Ansible, Terraform, and Docker. Fayaz has implemented Jenkins CI/CD pipelines to build, test, and deploy large apps, including microservices, with zero downtime.
Igor is an experienced automation architect with proven leadership ability. Passionate about improving organizational efficiency through utilizing automation strategies, he's capable of directing several initiatives simultaneously and maintaining a high standard of excellence in quality and speed. Igor's experience includes expertise with Java, JavaScript, Python, Selenium, Appium, Jest, Jasmine, NightwatchJS, Karate API, and UI.
Christina is a senior QA engineer with expertise in test automation, test management, and manual testing for web and mobile applications. She has created test automation frameworks from the ground up using Selenium WebDriver in several projects as well as automating API testing using REST-assured and Postman. With experience in both private and public sectors, Christina has worked with large, medium-size, and small startup companies.
Testing web applications and sites can be a daunting task, especially if you don’t have the right tools. Selenium aims to streamline this as much as possible, and having an expert Selenium automation engineer can tremendously benefit your project's development.
... allows corporations to quickly assemble teams that have the right skills for specific projects.
Despite accelerating demand for coders, Toptal prides itself on almost Ivy League-level vetting.
Our clients
Creating an app for the game
Leading a digital transformation
Building a cross-platform app to be used worldwide
Drilling into real-time data creates an industry game changer
Testimonials
Tripcents wouldn't exist without Toptal. Toptal Projects enabled us to rapidly develop our foundation with a product manager, lead developer, and senior designer. In just over 60 days we went from concept to Alpha. The speed, knowledge, expertise, and flexibility is second to none. The Toptal team were as part of tripcents as any in-house team member of tripcents. They contributed and took ownership of the development just like everyone else. We will continue to use Toptal. As a startup, they are our secret weapon.
Brantley Pace
CEO & Co-Founder
I am more than pleased with our experience with Toptal. The professional I got to work with was on the phone with me within a couple of hours. I knew after discussing my project with him that he was the candidate I wanted. I hired him immediately and he wasted no time in getting to my project, even going the extra mile by adding some great design elements that enhanced our overall look.
Paul Fenley
Director
The developers I was paired with were incredible -- smart, driven, and responsive. It used to be hard to find quality engineers and consultants. Now it isn't.
Ryan Rockefeller
CEO
Toptal understood our project needs immediately. We were matched with an exceptional freelancer from Argentina who, from Day 1, immersed himself in our industry, blended seamlessly with our team, understood our vision, and produced top-notch results. Toptal makes connecting with superior developers and programmers very easy.
Jason Kulik
Co-Founder
As a small company with limited resources we can't afford to make expensive mistakes. Toptal为我们提供了一位经验丰富的程序员,他能够立即投入工作并开始做出贡献. It has been a great experience and one we'd repeat again in a heartbeat.
Stuart Pocknee
Principal
How to Hire Selenium Developers Through Toptal
1
Talk to One of Our Industry Experts
A Toptal director of engineering will work with you to understand your goals, technical needs, and team dynamics.
2
Work With Hand-Selected Talent
Within days, we'll introduce you to the right Selenium developer for your project. Average time to match is under 24 hours.
3
The Right Fit, Guaranteed
Work with your new Selenium developer for a trial period (pay only if satisfied), ensuring they're the right fit before starting the engagement.
At Toptal, 我们对Selenium开发人员进行了彻底的筛选,以确保我们只为您匹配最优秀的人才. Of the more than 200,000 people who apply to join the Toptal network each year, fewer than 3% make the cut. 你将与工程专家(而不是一般的招聘人员或人力资源代表)一起了解你的目标, technical needs, and team dynamics. The end result: expert vetted talent from our network, custom matched to fit your business needs.
Can I hire Selenium developers in less than 48 hours through Toptal?
Depending on availability and how fast you can progress, you could start working with a Selenium developer within 48 hours of signing up.
What is the no-risk trial period for Toptal Selenium developers?
我们确保您和您的Selenium开发人员之间的每次约定都从长达两周的试用期开始. This means that you have time to confirm the engagement will be successful. If you’re completely satisfied with the results, we’ll bill you for the time and continue the engagement for as long as you’d like. If you’re not completely satisfied, you won’t be billed. From there, we can either part ways, 或者我们可以为您提供另一位可能更合适的专家,我们将与他开始第二轮谈判, no-risk trial.
Share
How to Hire a Great Selenium Developer
The Selenium project was born out of everyday work that Jason Higgins, Paul Gross and Jie Tina Wang did for ThoughtWorks some time during 2004. While showing Selenium to their colleagues, Paul Hammant saw big potential, and suggested open-sourcing Selenium and making it work in a driven mode which would make it accessible to other programming languages. Since it was open-sourced from the early days, a lot of people contributed to make it the robust web automation tool as it is today.
Selenium IDE also played a great role in making the Selenium project as popular and widespread as it is. Created as a Firefox plugin by Shinya Kasatani, this tool enabled users to record and then play back their browser actions as a set of Selenium core commands inside the browser. They could then save those actions to a file and reuse them later as a self-contained script.
Version 1 proved to be an interesting framework, and that opened the eyes of many people regarding the automation testing process. Version 2 built upon that, introduced WebDriver as an interface, and is about to become W3C standard. Selenium的WebDriver架构也被用作移动应用测试框架的起点,例如 Appium, Selendroid and iosdriver.
Selenium Library
Selenium makes automating web applications and sites a streamlined process. It uses methods for finding web page elements with selectors available in HTML4/HTML5/CSS standards. That way, whole burden of manually testing web application can be eased with the use of a few clever scripts. Selenium WebDriver interface makes it possible to use any modern browser and automate web sites and applications using HTML/CSS selectors that interact in a manner similar to a real user using their browser - just a tad faster.
Selenium actually consists of three separate components:
Selenium WebDriver (Selenium 2)
Selenium IDE
Selenium Remote Control
Selenium WebDriver knowledge is the key skill required, writing tests using Selenium driver is what we are looking for. Selenium Remote Control is a part of Selenium Server, a component that allows Selenium browser tests to run in parallel on dedicated servers grid, and is only an additional component for building an automated system.
虽然Selenium IDE非常适合新用户,并且可以快速尝试Selenium或被测系统的实际工作方式, it cannot be considered as a tool that will get the job done completely, since for a bigger project with a lot of functionalities there needs to be a lot of tests organized in a logical and readable manner. To create Selenium automated tests, coding skills, architectural skills, and technical knowledge are required, as is the case with any development process.
Questions and Answers
Selenium was made to be an easy-to-use framework by design, so that people with less technical experience can use it for regular needs. Anyone can actually write a script using Selenium IDE without even leaving the browser. But there is actually more than just a fine line between someone who can use it, someone who is good with it, and someone who mastered both Selenium development and testing process. Selenium developers need to be more than just coders and data driven in most of the cases. 在接下来的章节中,我们将看到在选择完美的候选人时可以评估哪些技能.
To Automate or Not to Automate
While debate about automation reach is still on, 没有人能否认Selenium作为web自动化事实上的标准的身份,以及它对测试世界的巨大影响. Some organizations have gone automation-crazy, and are not employing anyone without background in automation and development. QA Developers, Test Automation Engineers, Software Engineers in Test (SET) or however called by different organizations, 如今,将各种工具(包括Selenium)授权到被测系统的上下文中是非常需要的, and that trend will continue as long as development cycles are as fast as they are, and as web software becomes more and more sophisticated.
还会出现另一个问题:是否需要一个全职的专门的Selenium开发人员? 有人可能会说,编写应用程序及其特性代码的开发人员也可以使用Selenium创建自动化测试. And, in a lot of cases, that may be true.
There is no straight-forward answer to this question, since it depends on a lot of different factors such as project size, solution complexity, manpower, and deadlines. If a web developer needs to spend half of his working time automating and coding tests, that is not exactly being efficient. A dedicated Selenium developer with experience will spend much less time automating, will know from the beginning how to organize code in best way, and will also create a quality layer of tests. They can also give insights and tips about making these features act more user-friendly and efficient. Covering edge cases and situations that are not easy to test without automation can help create another layer of security for the end product. 这取决于你对产品的最终质量有多坚定,并从第一天起就让它发挥应有的作用.
Q: Is it always appropriate to automate a project and all of its features?
While it cannot be denied that automation can be quite usable in everyday development, there are situations in which automation is not appropriate, or even possible. Also, taking into consideration the test pyramid, it is not advisable to have too many automated UI tests and to depend a lot on them, since all major application features have to be covered on levels beyond (unit, services). Therefore, only crucial application features need to be tested using UI coverage. Some of the minor app functionality can be tested unattended by going through major application workflows and using specific unit tests for those components.
QA, Developer or Both?
Q: How are you seeing yourself predominantly, as the developer or QA?
What you are looking for is neither QA nor developer in their strict sense. In a world of continuous development, 您正在寻找一个拥有适合敏捷开发理念的广泛技能的人. That is especially the case with Selenium developers, maybe even more than with any other role in your team. They are certainly not traditional QA’s, and most of the time, they are not producing any code that is worth releasing out through the company doors. What they do is provide support code that can be crucial for cutting down testing time and expenses, and giving the product a support that goes well beyond just regular testing efforts.
They need to have QA skills nonetheless. Creating valid and meaningful test scenarios, testing edge cases, and then coding them as scripts should be a part of their everyday work. Selenium developers need to understand complex business logic and rules, because that is one of the requirements for making automation effort really worthwhile.
Selenium developers should not fear about getting their hands dirty doing manual testing, because let’s face it, you can automate a lot, but you don’t have to automate everything. Manual testing is still more than valid in situations where automated testing is not efficient and where human judgement is providing more information than a computer can provide. Computers are good in execution, but not in making judgements. So use humans for what they are best at. Automation starts where manual testing ends. Automation using Selenium WebDriver is always a successor of manual work, as it further validates good judgements made while manually testing an application.
Language-gnostic
Q: What language do you prefer when writing Selenium tests?
Selenium WebDriver is ported to many popular languages, so if you are looking for a Selenium expert, you don’t have to worry much about the language he uses. Unless of course, it is crucial to the actual business or company’s policies. Driver libraries are available for Java (native), C#, Python, Ruby and JavaScript. It should be quite easy for a seasoned Selenium developer to switch to any of the different languages. The driver libraries’ APIs are almost identical, leaving the emphasis on the languages best coding practices.
Let’s see how these differences look in practice:
Java:
import org.junit.AfterClass;
import static org.junit.Assert.*;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
public class TestToptal {
private static FirefoxDriver driver;
@Before
public static void initializeDriver(){
driver = new FirefoxDriver();
}
@Test
public void testTitle(){
driver.get("http://2m6.fontinagrup.com");
assertEquals(driver.getTitle(), "Hire the top 3% of freelance developers, designers, and other tech talent.");
}
@After
public static void closeBrowser(){
driver.quit();
}
}
Ruby:
require 'selenium-webdriver'
require 'minitest/autorun'
class TestToptal < Minitest::Unit::TestCase
def setup
@driver = Selenium::WebDriver.for :firefox
end
def test_title
@driver.get 'http://2m6.fontinagrup.com'
assert_equal @driver.title, "Hire the top 3% of freelance developers, designers, and other tech talent."
end
def teardown
@driver.quit
end
end
Python:
import unittest
from selenium import webdriver
class ToptalTest(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.driver = webdriver.Firefox()
def test_title(self):
self.driver.get("http://2m6.fontinagrup.com")
self.assertEqual(
self.driver.title,
"Hire the top 3% of freelance developers, designers, and other tech talent.")
@classmethod
def tearDownClass(cls):
cls.driver.quit()
As you can see for yourself, the differences are minor, and expect for the actual amount of code needed to be written.
HTML + CSS
It is a fact that one could automate web page or application testing using Selenium WebDriver without having any HTML or CSS skill. Selenium can provide selectors and action specifications, and these can be used directly. But there is a big advantage if the candidate has knowledge and understanding of HTML and CSS.
Q: How would you rate your HTML & CSS knowledge?
Even intermediate HTML and CSS knowledge could prove beneficial for Selenium developers dealing with the web application or site under test. Especially when it is a bit more markup heavy or complex.
Another benefit of knowing those two technologies is that it allows the Selenium developer to help front-end developers in a much more direct manner, or even by doing code reviews. Speaking from experiences of many organizations, involving project members into each other’s code proves to be beneficial to whole development process.
Q: What is CSS? How can it be used in test automation context?
CSS or Cascade Style Sheets is a declarative language that describes HTML presentation to end client. With CSS, plain HTML pages are rendered as beautifully styled documents.
While they may not be that important for actual test automation, a Selenium developer’s knowledge of CSS can help them choose better selectors. They can also use CSS attributes for advanced assertions if needed. They can help identify poorly written CSS so that front-end developers can fix them.
Q: Briefly describe the HTML4 page layout.
Every web page consists of at least a head and a body tag wrapped inside the HTML root element. While head holds some page specific metadata, everything relevant to the actual user interface is inside body tag, and is visible to the end user.
Selenium developers will spend their programming life inside the body tag, finding out the best ways to locate elements and do various manipulations and assertions.
Q: Is there any difference if a page is using HTML5 from a test automation standpoint?
No. HTML5 uses a specific set of tags in order to have more standardized and well annotated page layouts, but this has little to no effect on the actual test automation process. Although, this is also dependant on actual the web application being tested.
Q: What is HTML DOM?
Domain Object Model, or in short DOM, is a programming interface for the HTML page, and is constructed every time a page is loaded. It is a tree representing elements of a page as objects with their own properties, methods for manipulation and events that they react to. By using HTML object model, pages and their elements can be manipulated using JavaScript.
Advanced Web Browser Knowledge
It is quite important that a Selenium developer not only knows how to code, but also knows about browser capabilities. Firefox, Chrome, IE (Edge), Safari etc., all of them have subtle differences regarding page loading, element rendering and inner mechanics of how they process pages. One has to know all their quirks to be able to bend these tools to their needs. Selenium developers do not need to be exactly on a developer’s level of knowledge, but they need to know more about the browsers than any regular user. And this includes the use of tools that the browsers provide, such as Developer Console, Network Traffic, Performance tools and so on.
For example, Chrome has configuration profiles, which can be used for developers advantage, as a way of setting up test sets before each run, like loading of images on sites, working with different directories for downloads, turning off advanced or standard browser features. Same thing with Firefox, which has a similar set of hidden and not-so-hidden options in its arsenal. Mastering these will make developers life as an automation engineer much easier, and are quite important for testing the application in various scenarios.
今天的浏览器就像迷你操作系统(有些人甚至倾向于这样看待它们),提供了很多功能, 大多数普通电脑用户都将它们视为软件中最重要的部分, without even knowing they are not an integral part of it. Master them for a more joyful automation life.
JavaScript is a Friend in Need
It is also a big advantage if the candidate knows JavaScript. There are situations where JavaScript can be the only way of automating parts of application workflow. In 95% of cases, it is not required. But it can still be a distinguishing factor, specifically if the project is JavaScript heavy. Since it is possible to run or trigger JavaScript in the context of the Selenium WebDriver, making it part of the automated solution is a straight-forward process.
A lot of modern projects are using JavaScript almost exclusively for both backend (server side) and front-end (client side) development, and having that knowledge keeps Selenium developers in sync with the rest.
Selenium开发人员还可以帮助检查JavaScript代码,帮助修复bug或在bug出现之前找到它们. And that is something which could become invaluable for your team and its success.
Q: How would you call a JavaScript object or method using Selenium Driver?
可以使用Java中的JavascriptExecutor类在驱动程序的上下文中直接调用JavaScript, and similarly in other languages. Script can be executed synchronously or asynchronously:
Selenium IDE使Selenium对于任何想要快速进入web自动化的初学者来说都非常简单. But to make efficient and reliable scripts, it is much better to have code organized into re-usable units. While it is possible to use Selenium IDE for recording and playing back actions, it is quite a nuisance to sustain that code through agile development, where a lot of features are changed rapidly and frequently. So, if you are looking for an expert, you are looking for someone who is also a good developer.
Q: How should you organize automation code?
It is also a big advantage if Selenium test code is organized using Page Object pattern, that is discussed a few paragraphs later. Test code that are decoupled from support code can further improve maintainability. There are few guidelines though:
Keep custom support libraries out of actual test code
Make workflow helper methods that can be reused between tests
Use Page Objects to organize code
Remove old irrelevant code
Remove tests that are already covered while adding new functionality
Since automated tests change quite fast, it’s advisable to change it as fast as development goes.
Testing Libraries to Wrap Tests Up
A big part of organizing test code actually involves the use of test unit/spec/features library that will make test assertions and checks a part of the workflow. It is possible to do actual test scripts without them, but they do provide an additional level of control, especially if project is using CI (Continuous Integration) servers as part of the development process.
Q: What is your experience with testing libraries?
Testing library selection will vary depending on programming language that is actually being used. 但是它们有一个共同点:断言Selenium执行的操作产生了预期的结果, be it a web element being displayed, text being rendered or anything else that can happen on the browser’s interface. Some of the most popular libraries by languages are:
Java: jUnit, TestNG
Ruby: rspec, minitest
Python: py.test, unittest, nose
Q: Do you have experience writing Cucumber features?
One interesting library that deals with features is Cucumber, where tests specified in a way similar to business specifications that even people with no technical knowledge can read and understand:
Scenario: Downloading business report
Given I am signed in as manager
When I search for "latest report"
Then report list should contain "report from last day"
This way, tests become even more communicative, while programming implementation is kept out of business requirements. 如果您有许多想要参与测试的涉众,那么这是一项再强调不过的技能, and who do not have actual technical skills to interpret code by themselves.
Page Object Pattern
Q: Have you used Page Objects? How are they useful?
Introduced in Java Selenium library version 2, Page Object pattern is a great way for organizing code into reusable classes. Consider part of the code code below that is automating Toptal site application:
It does the work, but it is not likely to be reusable or easily extendable if that workflow changes for any reason. Using Page Object pattern, this simple test becomes a highly reusable class that can be initialized and used in multiple tests:
package com.fontinagrup.common.pageobjects;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
public class SignUpPage {
private final WebDriver driver;
private By talentDiv = By.CssSelector("div[data-role='custom_field']");
private By developerDiv = By.CssSelector("div[data-value='Developer']");
private By designerDiv = By.CssSelector("div[data-value='Designer']");
private By emailField = By.Id("talent_email");
private By passwordField = By.Id("talent_password");
private By passwordConfirmField = By.Id("talent_password_confirmation");
private By fullNameField = By.Id("talent_full_name");
private By skypeNameField = By.Id("talent_skype");
private By saveTalentButton = By.Id("save_new_talent");
public SignUpPage(WebDriver driver) {
this.driver = driver;
if (!verifyBasePageTitle) {
throw new IllegalStateException("This is not the Sign Up page");
}
}
public String getPageTitle() {
String title = driver.getTitle();
return title;
}
public boolean verifyBasePageTitle() {
String expectedPageTitle="Exclusive Access to Top Developers and Designers | Toptal";
return getPageTitle().contains(expectedPageTitle);
}
public SignUpPage selectTalent(String talent) {
driver.findElement(talentDiv).click();
if talent.equals(developerValue.text) {
driver.findElement(developerDiv).click();
} else if talent.equals(designerDiv.text) {
driver.findElement(designerDiv).click();
} else {
driver.findElement(By.CssSelector(String.format("div[data-value='%s']", talent)).click();
}
return this;
}
public SignUpStepTwo applyAsDeveloper(String email, String password, String fullName, String skypeName) {
driver.selectTalent("Developer");
driver.findElement(emailField).sendKeys(email);
driver.findElement(passwordField).sendKeys(password);
driver.findElement(passwordConfirmField).sendKeys(password);
driver.findElement(fullNameField).sendKeys(fullName);
driver.findElement(skypeNameField).sendKeys(skypeName);
driver.findElement(saveTalentButton).click();
return new SignUpStepTwo(driver);
}
}
What directly comes to mind is that Page Object makes most sense as an exact counterpart of what actually happens within browser when a user is working with it, like a mind that drives the page in pursuit of its goal.
There are different Page Object libraries for different languages, but they all have some things in common: they are making logical placement of all elements on page, and are also providing convenient methods for accessing any feature that is present on that page. They can also be used as routers, where Page Object are created after web application actions and chained in a logical structure that is same as one of the system under test. You can then combine them with wait states to create a sophisticated machinery that will drive your tests and contain all logic important for execution.
Q: Should Page Object be an exact copy of real page (have all elements as separate objects)?
No. Since there are usually a lot of elements on each page, 只有那些创建工作流自动化所必需的元素应该在Page Object中建模. 把每个元素都放在页面上实际上是适得其反的,因为它使页面对象变大了, clumsy, hard to maintain and almost unusable.
Q: Is it advisable to make assertions directly in page object?
It should be avoided. Page Objects做得最好的是通过一个干净的API保持和公开页面结构和页面的内部逻辑. One could make a Page Object verify some state of an element, but it should never assert directly.
Selenium Specifics
Q: Which element selectors are considered most optimal?
It is quite easy to create Selenium driver scripts that test some functionality. It is even easier to make it hard to change and support scripting code later, either by using complicated selectors that are too dependent on page structure, or not following Page Object pattern while developing test scripts. Best selectors are those that are most distinctive, and at the same time, simplest to follow as application grows and changes its layout.
This also begs another question: what selectors are actually best for locators of page elements? While pragmatic ones can say that anything that works is good enough, there is actually a hierarchy that is best to follow:
id > name > class >= css_selector > tag > text > xpath
This is also debatable, but to sum the logic behind it, IDs are locators that are most distinctive per page and therefore should be used first. Element names can also be quite distinctive. CSS classes are also great, especially on web pages that are well formed using distinctive CSS classes.
Sometimes it is highly desirable that actual link text is used as selector, 因为测试可以在选择页面元素时直接在界面上捕获任何拼写错误或功能问题.
Q: Briefly explain advanced CSS selectors usage.
When everything else fails, advanced CSS selectors are the best bet in finding elements or groups of elements on a page. Here are some of the most frequently used ones:
Direct child: div > a
Child or subchild: div a
Specific id: div#myid a
Specific class: div.myclass a
Specific match: ul#mylist li:nth-child(2)
CSS selectors can also be used to search the content of a page, but that’s a topic of its own.
Q: What should you do when there are two elements that do not have anything distinctive?
Once in awhile there will be a situation where two elements on a page have every part of HTML / CSS tag that are exactly the same, including element text, but they do have different functionality that needs to be automated. There are multiple ways to solve this:
Use findElements method that returns a list of elements. Then it would be possible to access any element of the list by index
Use CSS / XPATH specific matcher and match exact occurrence of an element
Q: What will happen if an element selector is the same for multiple elements on page?
Only first occurrence of the element will be selected, and since page is read from top to bottom, that will be the element nearest to the top of the document.
Mastering Timeouts
Q: State the difference between explicit and implicit waits.
Web pages usually consist of a lot of different elements, such as links, paragraphs, buttons, input fields, text fields, combo boxes and custom objects. And most of them are loaded as soon as whole page is loaded, and they can be accessed almost instantly after being loaded. But there are situations where elements are loaded asynchronously, waiting for server response, or response from some external service provider.
当您知道一个元素是否可用于自动化的唯一方法是等待它完全加载时, Selenium WebDriver provides waits. They can be explicit or implicit. 隐式等待就像在访问元素之前总是等待3秒,或者每0轮询一次DOM.5 seconds to determine if a condition is met. Explicit waits check directly if an element condition is true, and pauses the script execution until that exact condition is met, throwing timeout error if it’s not met after a set duration.
WebDriverWait wait = new WebDriverWait(driver, 5);
wait.until(ExpectedConditions.elementToBeClickable(By.id("myid")));
As you can see, the implicit wait is being done on driver level, so that whenever a new page opens, before actual element lookup is done, driver will wait for 5 seconds minimum. In reality, there are situations in which you will have to use a combination of both, although explicit waits are generally considered better practice. Implicit waits are definitely better in situations where tests can be made more reliable. Using explicit waits will make tests work much faster, which can also be quite important. Using waits wisely is the key. If the application is AJAX heavy, appropriate wait states are crucial for making automation work reliably.
HTTP Rules
So, what actually happens in a browser when you are navigating from page to page? web上的一切都是从向服务器发出HTTP GET请求开始的,并从服务器获得各种不同形式的响应, be it complete web pages, images, sounds or simple responses that hold data that is used in a context of application. The internet of today is a mixture of many technologies, but in its core, it’s still the same old HTTP protocol that is ruling Internet from its beginning. With a plethora of APIs from swarms of vendors, 今天的应用程序之间的联系更加紧密,有时很难将一个应用程序与其他应用程序隔离开来. There is a recent trend of making applications in two layers, an API layer with so called microservices (backend) and a UI level (frontend) as separate units of work that are communicating with each other. With that sort of separation, Selenium tests are actually becoming not only features, but sort of integration tests, and their value is becoming even more evident.
While it is not an urgent need for a Selenium developers to know a lot about HTTP, it can help them do automation in a lot of ways, especially if the application is using a lot of external APIs. He could record responses and then mock them inside tests for their speed and reliability, he could also make direct HTTP calls as they are part of application. He could even make separate tests for API application layer, using tools of his choice.
Q: Which methods are considered secure in browser?
For security reasons, only OPTIONS, GET, HEAD, POST, PUT, and DELETE are allowed inside web browsers. Methods such as TRACE and CONNECT are not allowed. Old browsers such as Internet Explorer had even more limited support for HTTP methods.
Q: How can the use of parameters in URL affect automation?
A lot of web applications are using parameters inside their URLs, and that can be great when testing something specific, without a need to go through complicated workflows of the application. Consider this example:
By this approach, it would be possible to parametrize a test and verify conditional behavior without going through the whole application workflow.
Combine Selenium with Other Tools and Libraries
While you can do a lot by automating web sites and applications using Selenium WebDriver, there will come a situation where something more is needed. For example, you can combine Selenium automation with database tests, to verify if data is correctly stored inside database. You can even create test reports that are logging everything that was done inside automated tests and have it saved in various formats, for future reference or for CI reports.
Speaking of CI, it would be more than beneficial for Selenium developers to have knowledge about them. CI servers are there to run all kinds of tests, building application and packing them to self-contained bundles. One can use headless drivers / browsers, such as PhantomJS to run tests on CI servers, or use xvfb to run real browsers without actually running display servers. Whatever you choose, CI are invaluable for making test automation a tool that every member of team can rely on. Knowing how to set them up and prepare for running Selenium or any other kind of unit or integration tests can become crucial to the development’s success.
Communication
Programming is, in its core, communication. Not only between human and machine, but also between programmers themselves. Using code to communicate with each team member is one skill that is easy to overlook, because let’s face it, no one knows what tomorrow brings: someone else will join the project, some parts of application will miss documentation and no one will know how it was coded, or you will find yourself explaining parts of code you did before every time someone tries to use it. 不可读的代码会让您感到悲伤,觉得您或其他人首先应该做得更好. Documentation is great, but code itself needs to be clear and as communicative as possible.
For a Selenium developer, it is of utmost importance that they give their objective opinion about everything inside project, be it code, design, feature set and implementation, and to communicate that back and forth between each and every member of a team. That’s not as easy as it might appear, since we are all human, have our own opinions, have our own pride, and sometimes that mix can become an obstacle in making the right decisions and make project progress. Mastering communication is not something that can be taught in school, at least not as a part of any official studies. This is part of social intelligence, which not everyone has.
Knowing English well is a big part of online communication, especially in coding and when working on freelance projects. Therefore it is important to gauge the candidate’s language skills beforehand.
Wrap Up
Web projects of today cannot be seen without some sort of automation as their foundational parts. Using any of Selenium’s supported languages, well created automated tests and test suites can provide a safety net that ensures that any regression is caught before it hits production, and that development becomes reliable and a pleasurable process. Version 3 of Selenium is in the making, and it will be an evolution of an already established legacy. The question is not whether you should have automation, the question is how dedicated to automation and quality assurance your team is, and how much you can invest in it.
It is absolutely a best practice to start automating a project from day one, 并且拥有一个具有开发经验的Selenium自动化工程师是一个很大的加分项.
If your project still does not have Selenium tests, and there is a need for automation, do not hesitate. Start now! The difference will be huge, for both software development and team morale. Automation is not a magic wand that will make all project problems disappear, but it will at least make them more visible.