Popular New Releases in Functional Testing
selenium
Selenium 4.1.0
nightwatch
v2.1.0
pytest
testcontainers-java
1.17.1
docker-selenium
4.1.3-20220405
Popular Libraries in Functional Testing
by SeleniumHQ java
23180 Apache-2.0
A browser automation framework and ecosystem.
by Kr1s77 python
13481 NOASSERTION
😮python模拟登陆一些大型网站,还有一些简单的爬虫,希望对你们有所帮助❤️,如果喜欢记得给个star哦🌟
by nightwatchjs javascript
11057 MIT
End-to-end testing framework written in Node.js and using the W3C Webdriver API
by teamcapybara ruby
9531 MIT
Acceptance test framework for web applications
by angular javascript
8761 MIT
E2E test framework for Angular apps
by pytest-dev python
8655 MIT
The pytest framework makes it easy to write small tests, yet scales to support complex functional testing
by wistbean python
7711 MIT
python爬虫教程系列、从0到1学习python爬虫,包括浏览器抓包,手机APP抓包,如 fiddler、mitmproxy,各种爬虫涉及的模块的使用,如:requests、beautifulSoup、selenium、appium、scrapy等,以及IP代理,验证码识别,Mysql,MongoDB数据库的python使用,多线程多进程爬虫的使用,css 爬虫加密逆向破解,JS爬虫逆向,分布式爬虫,爬虫项目实战实例等
by testcontainers java
5847 MIT
Testcontainers is a Java library that supports JUnit tests, providing lightweight, throwaway instances of common databases, Selenium web browsers, or anything else that can run in a Docker container.
by SeleniumHQ shell
5759 NOASSERTION
Docker images for the Selenium Grid Server
Trending New libraries in Functional Testing
by g1879 python
539 BSD-3-Clause
A module that integrates selenium and requests session, encapsulates common page operations, can achieve seamless switching between the two modes.
by mxschmitt javascript
531 MIT
Playwright for Go a browser automation library to control Chromium, Firefox and WebKit with a single API.
by pcomputo python
459 Apache-2.0
Automated script for Whole Foods and Amazon Fresh delivery slot
by AmmeySaini python
364 MIT
Generate Free Edu Mail(s) within minutes
by ethicalhackingplayground java
226 MIT
SSRF plugin for burp Automates SSRF Detection in all of the Request
by mrwn007 python
194
auto report instagram accounts ( SPAM BOT )
by ElSnoMan python
171 MIT
Bring the best of Selenium and Cypress into a single Python package
by dunossauro python
169 CC0-1.0
Repositório de curso de selenium usando python
by oslo254804746 python
156 Apache-2.0
Pytest测试框架,UI, API, DataBase,部分功能已封装,可根据实际需求修改
Top Authors in Functional Testing
1
38 Libraries
661
2
36 Libraries
207
3
29 Libraries
86
4
25 Libraries
21330
5
18 Libraries
209
6
15 Libraries
54
7
15 Libraries
10956
8
11 Libraries
46
9
11 Libraries
573
10
11 Libraries
252
1
38 Libraries
661
2
36 Libraries
207
3
29 Libraries
86
4
25 Libraries
21330
5
18 Libraries
209
6
15 Libraries
54
7
15 Libraries
10956
8
11 Libraries
46
9
11 Libraries
573
10
11 Libraries
252
Trending Kits in Functional Testing
Functional testing is a type of software testing in which applications are tested for their intended functionality. It's also called black-box testing because the internal code isn't examined. Instead, testers look at the inputs and outputs of an application to see if they match up with what they're supposed to be. In order to use JavaScript in testing, you will need a browser or a browser automation tool. We will look at the 8 best JavaScript open-source functional testing libraries including cypress - Fast, easy, and reliable testing for anything that runs in a browser; enzyme - JavaScript Testing utilities for React; react-testing-library - Simple and complete React DOM testing utilities.
Functional testing is a software testing technique that involves testing the end-to-end business flow of an application. It checks whether the application provides the required output or not when given a specific input. Functional testing makes sure that the application is working as per specification. Functional testing is done to verify business requirements, while non-functional testing includes security, load, and performance testing. We will look at six open source functional testing libraries for Java like galen - Layout and functional testing framework for websites; FluentLenium - mobile automation framework which extends Selenium; Cognizant-Intelligent-Test-Scripter - Scriptless Test Automation Solution.
Functional testing is the process of checking that individual software components are working as expected. It is intended to verify the correctness of a system’s behavior by inputting data and checking the output values. With the rise in popularity of Ruby, many developers are working on new applications and APIs. As a result, this has led to the emergence of a number of testing libraries that have come along to make their lives much easier. Here we will discuss some of the best Ruby Functional testing Open Source libraries including factory_bot - A library for setting up Ruby objects as test data; shoulda-matchers - Simple oneliner tests for common Rails functionality; appraisal - Ruby library for testing your library against different versions.
Web application functional testing is a very important part of software development. The functional testing process helps to ensure that your web application functions as it should. It's an essential part of software development and critical in terms of satisfying your customers' needs. The functional testing process can be done manually or automatically. There are many libraries for Python functional testing. Let us see the 10 best Python functional testing libraries. Pytest - framework makes it easy to write small tests, yet scales; python-testing-crawler - automated functional testing of a web application; FunkLoad - load testing framework for web applications
Functional testing is a type of software testing, which verifies that each function of the software application operates in conformance with the requirement specification. C++ libraries are basically a collection of functions that can be reused repeatedly in programs. Most of the libraries use object-oriented programming principles and some of them are written in C language. In this kit, we'll list some of the best C++ libraries that can be used for testing purpose: oovaide - C and Java automated analysis, class, component and sequence UML diagramming IDE tool, test coverage, complexity, duplicate code, analysis statistics; cpp-project-template - A simple template for C++ projects: CMake, Unit tests, Continous Integration all set up and ready to go.
PHP Functional testing library are used by developers to validate the source code of their projects. It's aimed at supporting automated testing and continuous integration, making it easier for developers to write reliable, high-quality PHP software. Though there is an abundance of PHP functional testing libraries, many developers still have trouble choosing one. This is not surprising, considering that the selection is wide and complex. To help you choose a library for functional testing your web application, we compiled a list of 11 best PHP functional testing Open Source libraries in 2022. LiipFunctionalTestBundle - Some helper classes for writing functional tests in Symfony; wp-browser - Easy acceptance, functional, integration, and unit testing; steward - PHP libraries that make Selenium WebDriver.
The functional testing process helps to ensure that your web application functions as it should. It's an essential part of software development and critical in terms of satisfying your customers' needs. The functional testing process can be done manually or automatically. It is intended to verify the correctness of a system’s behavior by inputting data and checking the output values. There are many libraries for C# functional testing. Let us see the 10 best C# functional testing libraries. clean-architecture-manga - Clean Architecture with .NET5, C#9 and ReactRedux; Coyote - a .NET library and tool designed to help ensure that your code is free of concurrency bugs; BotFramework-FunctionalTests - Functional Tests, run nightly, to drive quality.
Functional testing makes sure that the application is working as per specification. Functional testing is done to verify business requirements, while non-functional testing includes security, load, and performance testing. There is a myriad of testing tools and frameworks available for Go, but some of them are not suited for functional testing. A functional test is an automated test that checks the features and functionality of a web application. In this kit, we will review some of the best Go frameworks to help you get started with functional testing. iris - The fastest HTTP/2 Go Web Framework; k6 - A modern load testing tool, using Go and JavaScript; test-infra - Test infrastructure for the Kubernetes project.
Trending Discussions on Functional Testing
Why ASP.NET Core web application does not serve static web assets when started from command line?
Testing EJB interceptor using spring
Using async await on .then function with parameters
How to to do smoke testing for Azure Data Factory based pipeline
Selenium Python Pytest testing a web page using parametrized tests. ElementClickInterceptedException
Should contract testing be avoided for message queues where we're sending data packets (not requests)?
Troubleshoot failing NUnit Selenium tests in Azure DevOps
how to run a node.js github repository as a service in another repository on github actions
How to access spark history server
How can you programmatically raise a conditional PR?
QUESTION
Why ASP.NET Core web application does not serve static web assets when started from command line?
Asked 2021-Dec-20 at 13:41This title would be too long, but this is more isolated issue:
Why ASP.NET Core web application does not serve static web assets when started from command line and the ASPNETCORE_ENVIRONMENT
is not set, or set to any other value than "Development"
?
Context
I've created a new ASP.NET Core Web Application using the VS 2022 built in template (.NET 6, but I do not think the issue/question is .NET 5 specific) I did not altered the created application in any way
I am able to run my ASP.NET Core web application under IIS Express, or without IIS Express using Visual Studio, based on launchsettings.json.
, I mean using the green triangle dropdown, and pick WebApplication instead IIS Express
Just for the sake of curiosity, I've tried to launch the WebApplication1.exe from the bin folder. It starts, I can access it via browser using https://localhost:5001/, the page loads, but without CSS, JS. I can see that all requests for static resources have a 404 response.
I suspect that I should somehow configure the app, where the static web resources are. I see that the corresponding WebApplication1.runtimeconfig.json
and WebApplication1.staticwebassets.runtime.json
(formerly WebApplication1.staticwebassets.xml
) are there... but later I figured out that magically the environment ASPNETCORE_ENVIRONMENT
is related to the issue.
What I've tried so far?
In the command shell I set the environment variable to
1SET ASPNETCORE_ENVIRONMENT=Development
2
...then started then I started WebApplication.exe, this case all is working, static web assets are served.
Question
In the very simple Program.cs and startup code I do not see any conditional logic regarding ASPNETCORE_ENVIRONMENT
variable, so I do not understand the issue, why is the difference? (I've also checked the differences between the two appsettings.json
and appsettings.Development.json
: no related differences.
As an ultimate goal, I would like to automate the start of the WebApplication.exe
for functional testing purposes, and I would like to start it sometimes as ASPNETCORE_ENVIRONMENT=Development
but other times without that setting.
Why is the difference regarding static web assets serving depending on ASPNETCORE_ENVIRONMENT=Development
, and how to run and serve static web assets without that setting from command line?
ANSWER
Answered 2021-Dec-20 at 13:41The question is a bit misleading, as the artifacts in bin/Debug folder is for debugging and not for general testing, so it is not guaranteed to work or supposed to work as you described.
The reason why you found it is not working is because there is no static assets in bin/Debug folder. It works in development environment and not in production (the default when no environment set) because the default builder calls UseStaticWebAssets
only in development environment.
Inside UseStaticWebAssets
, it processes .staticwebssets.runtime.json
file to resolve the real path of your static assets. That is how it works and why it does only when environment is development.
If you want to have it works as it supposes to, you should publish your project to a folder and call the executable from there. The publish tool will also publish your static assets into that folder so it will work whether you set the environment config or not.
QUESTION
Testing EJB interceptor using spring
Asked 2021-Nov-17 at 08:50I want to test (using functional testing) a EJB service that is being intercepted by an EJB Iterceptor. This application is running on a WildFly server.
The test:
1@RunWith(SpringJUnit4ClassRunner.class)
2@ContextConfiguration(classes = {FooServiceTest.ClassContextTest.class})
3public class FooServiceTest {
4
5 @Autowired public FooServiceImpl service;
6
7 @Test
8 public void createTest() throws Exception {
9 Foo foo = new Foo();
10 // ...
11 service.create(foo);
12 // ...
13 }
14
15 @Configuration
16 public static class ClassContextTest {
17 @Bean
18 public FooServiceImpl produceService() {
19 return new FooServiceImpl();
20 }
21
22 @Bean
23 public FooDao produceDao() {
24 //...
25 }
26 }
27}
28
The service:
1@RunWith(SpringJUnit4ClassRunner.class)
2@ContextConfiguration(classes = {FooServiceTest.ClassContextTest.class})
3public class FooServiceTest {
4
5 @Autowired public FooServiceImpl service;
6
7 @Test
8 public void createTest() throws Exception {
9 Foo foo = new Foo();
10 // ...
11 service.create(foo);
12 // ...
13 }
14
15 @Configuration
16 public static class ClassContextTest {
17 @Bean
18 public FooServiceImpl produceService() {
19 return new FooServiceImpl();
20 }
21
22 @Bean
23 public FooDao produceDao() {
24 //...
25 }
26 }
27}
28@Stateless
29@Interceptors({ValidationInterceptor.class})
30public class FooServiceImpl implements FooService {
31
32 private FooDao dao;
33
34 @Inject
35 public void setDao(FooDao dao) {
36 this.dao = dao;
37 }
38
39 public void create(@Valid Foo foo) {
40 // ...
41 dao.create(foo);
42 // ...
43 }
44
45 //...
46
47}
48
the interceptor:
1@RunWith(SpringJUnit4ClassRunner.class)
2@ContextConfiguration(classes = {FooServiceTest.ClassContextTest.class})
3public class FooServiceTest {
4
5 @Autowired public FooServiceImpl service;
6
7 @Test
8 public void createTest() throws Exception {
9 Foo foo = new Foo();
10 // ...
11 service.create(foo);
12 // ...
13 }
14
15 @Configuration
16 public static class ClassContextTest {
17 @Bean
18 public FooServiceImpl produceService() {
19 return new FooServiceImpl();
20 }
21
22 @Bean
23 public FooDao produceDao() {
24 //...
25 }
26 }
27}
28@Stateless
29@Interceptors({ValidationInterceptor.class})
30public class FooServiceImpl implements FooService {
31
32 private FooDao dao;
33
34 @Inject
35 public void setDao(FooDao dao) {
36 this.dao = dao;
37 }
38
39 public void create(@Valid Foo foo) {
40 // ...
41 dao.create(foo);
42 // ...
43 }
44
45 //...
46
47}
48public class ValidationInterceptor {
49
50 private Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
51
52 @AroundInvoke
53 public Object intercept(InvocationContext ctx) throws Exception {
54
55 Object[] paramValues = ctx.getParameters();
56 Parameter[] params = ctx.getMethod().getParameters();
57 for (int i = 0; i < params.length; i++) {
58 if (params[i].isAnnotationPresent(Valid.class)) {
59 Object value = paramValues[i];
60 valid(value);
61 }
62 }
63 return ctx.proceed();
64 }
65
66 private void valid(Object value) throws ConstraintViolationException {
67 Set<ConstraintViolation<Object>> violations = validator.validate(value);
68 if (!violations.isEmpty()) {
69 Set<ConstraintViolation<?>> cvs = new HashSet<>();
70 for (ConstraintViolation<?> cv : violations) {
71 cvs.add(cv);
72 }
73 throw new ConstraintViolationException(cvs);
74 }
75 }
76}
77
My test managed to test the service, the DAO and the mapper but the interceptor is not called at all. I am guessing it's because I use an JavaEE interceptor in a Spring test but I have no idea how to make that working. I am using Spring 4.3 and JavaEE 7.
ANSWER
Answered 2021-Nov-17 at 08:50I used weld-junit4 to use weld as a ontainer instead of Spring.
1@RunWith(SpringJUnit4ClassRunner.class)
2@ContextConfiguration(classes = {FooServiceTest.ClassContextTest.class})
3public class FooServiceTest {
4
5 @Autowired public FooServiceImpl service;
6
7 @Test
8 public void createTest() throws Exception {
9 Foo foo = new Foo();
10 // ...
11 service.create(foo);
12 // ...
13 }
14
15 @Configuration
16 public static class ClassContextTest {
17 @Bean
18 public FooServiceImpl produceService() {
19 return new FooServiceImpl();
20 }
21
22 @Bean
23 public FooDao produceDao() {
24 //...
25 }
26 }
27}
28@Stateless
29@Interceptors({ValidationInterceptor.class})
30public class FooServiceImpl implements FooService {
31
32 private FooDao dao;
33
34 @Inject
35 public void setDao(FooDao dao) {
36 this.dao = dao;
37 }
38
39 public void create(@Valid Foo foo) {
40 // ...
41 dao.create(foo);
42 // ...
43 }
44
45 //...
46
47}
48public class ValidationInterceptor {
49
50 private Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
51
52 @AroundInvoke
53 public Object intercept(InvocationContext ctx) throws Exception {
54
55 Object[] paramValues = ctx.getParameters();
56 Parameter[] params = ctx.getMethod().getParameters();
57 for (int i = 0; i < params.length; i++) {
58 if (params[i].isAnnotationPresent(Valid.class)) {
59 Object value = paramValues[i];
60 valid(value);
61 }
62 }
63 return ctx.proceed();
64 }
65
66 private void valid(Object value) throws ConstraintViolationException {
67 Set<ConstraintViolation<Object>> violations = validator.validate(value);
68 if (!violations.isEmpty()) {
69 Set<ConstraintViolation<?>> cvs = new HashSet<>();
70 for (ConstraintViolation<?> cv : violations) {
71 cvs.add(cv);
72 }
73 throw new ConstraintViolationException(cvs);
74 }
75 }
76}
77public class FooServiceTest {
78 @Rule
79 public WeldInitiator weld = WeldInitiator.from(FooServiceImpl.class, this.getClass()).build();
80
81 public FooServiceImpl service;
82
83 private static DataSource ds;
84
85 @BeforeClass
86 public static void beforeClass() {
87 ds = h2DataSource();
88 }
89
90 @Test
91 public void createTest() throws Exception {
92 Foo foo = new Foo();
93 // ...
94 service.create(foo);
95 // ...
96 }
97
98 @Produces
99 public FooDao produceDao() {
100 FooDao dao = new FooDao() {};
101 dao.setDataSource(ds);
102 return dao;
103 }
104
105 public static DataSource h2DataSource() {
106 return new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.H2).addScript("my/path/scripts.sql").build();
107 }
108}
109
This way I was able to use JavaEE injection for @Interceptors
and @Inject
and use Spring to mock the database using H2.
QUESTION
Using async await on .then function with parameters
Asked 2021-Nov-10 at 13:26I'm doing some functional testing with mocha. I stored my functions name, parameters and sucess message in local JSON file. I am checking my database response with local JSON response. I'm using .then and .catch everywhere. I am looking to clean up a code with async await. How I can use async await here?
1it('Check Authentication', (done) => {
2 readFileData('checkAuth').then(({ params, message}) => {
3 login.checkAuth({ ...params })
4 .then((result) => {
5 assert(result.message === message);
6 done();
7 })
8 .catch((err) => done(err));
9 });
10});
ANSWER
Answered 2021-Nov-10 at 13:26Something like this. Haven't tested it tho. Basically instead of .then()
you just await
the call. Note that there is async
before (done)
callback. .catch()
can be caught with try/catch
block.
1it('Check Authentication', (done) => {
2 readFileData('checkAuth').then(({ params, message}) => {
3 login.checkAuth({ ...params })
4 .then((result) => {
5 assert(result.message === message);
6 done();
7 })
8 .catch((err) => done(err));
9 });
10});it('Check Authentication', async (done) => {
11 let response = await readFileData('checkAuth');
12 try {
13 let message = await login.checkAuth({ ...response.params }); // or w/e the response is
14 // assert the message
15 } catch (e) {
16 // do something with the error
17 }
18 });
19
QUESTION
How to to do smoke testing for Azure Data Factory based pipeline
Asked 2021-Nov-02 at 09:19I have On-premise SQL Server->ADF->Storage->ADF->Azure SQL pipeline. I'm using Azure DevOps. ADF pipelines are executed every night and ADF monitor displays errors if such exists.
I wonder if there is ADF or other frameworks for doing build specific smoke testing before functional testing etc.
ANSWER
Answered 2021-Nov-02 at 09:19Unfortunately, there is no in-built feature in ADF to perform smoke testing. You need to manage it programmatically.
Alternatively, instead of triggering the pipeline directly it's better to run the debug and check for any error. There is also Mapping data flow debug mode for Data Flow pipelines which actually runs each step in the data flow before executing/triggering the final pipeline.
You can visit Integrating Smoke Tests into your Continuous Delivery Pipeline and check if this can be applied to your case.
QUESTION
Selenium Python Pytest testing a web page using parametrized tests. ElementClickInterceptedException
Asked 2021-Jul-01 at 08:52The same test runs as expected with all the parameters except '31' which results in ElementClickInterceptedException
Basically, this test has to check the max and minimum input length for the user name field and as an expected outcome the element which css selector is p[class="validation-message ng-star-inserted"]
has to appear ONLY if the length is not accepted and the assert message appears in console where you run this code
my test file:
1import pytest
2import sys
3import time
4from selenium.webdriver.common.by import By
5from pages.main_page import MainPage
6
7link = "https://rozetka.com.ua/"
8test_len_list = [str(num) for num in range(0,100)]
9test_len_list = ['a' for num in range(0, 33)]
10test_len_str = "".join(test_len_list)
11
12class TestRegisterPage():
13 @pytest.mark.len
14@pytest.mark.parametrize('num', [0, 1, 2, 31, 32, 64, 128,256])
15def test_field_username_len(self, browser, num):
16 # is it functional testing if I need to make a sequence of steps before reaching to the element I need to test
17 # Because if some step from this sequence won't work the entire test fails
18
19 if num <= 0:
20 field_value = ''
21 else:
22 test_len_list = ['в' for b in range(0,
23 num)]
24 field_value = "".join(test_len_list)
25 page = MainPage(browser, link)
26
27 #check if internet connection is present
28 if not has_connection(page.browser):
29 print('No Internet connection, aborted!')
30 page.browser.quit()
31 else:
32 page.open()
33
34 log_in_btn = page.browser.find_element_by_css_selector("button[class='header__button ng-star-inserted'][type='button']")
35 log_in_btn.click()
36 register_btn = page.browser.find_element_by_css_selector("a[class='auth-modal__register-link ng-star-inserted']")
37 register_btn.click()
38 # time.sleep(3)
39 username_input = page.browser.find_element_by_css_selector("input[id='registerUserName']")
40 username_input.send_keys(field_value)
41 time.sleep(3)
42 assert page.is_element_present(
43 'p[class="validation-message ng-star-inserted"]') == False, "Lenght does not satisfy the requirements"
44
my MainPage file:
1import pytest
2import sys
3import time
4from selenium.webdriver.common.by import By
5from pages.main_page import MainPage
6
7link = "https://rozetka.com.ua/"
8test_len_list = [str(num) for num in range(0,100)]
9test_len_list = ['a' for num in range(0, 33)]
10test_len_str = "".join(test_len_list)
11
12class TestRegisterPage():
13 @pytest.mark.len
14@pytest.mark.parametrize('num', [0, 1, 2, 31, 32, 64, 128,256])
15def test_field_username_len(self, browser, num):
16 # is it functional testing if I need to make a sequence of steps before reaching to the element I need to test
17 # Because if some step from this sequence won't work the entire test fails
18
19 if num <= 0:
20 field_value = ''
21 else:
22 test_len_list = ['в' for b in range(0,
23 num)]
24 field_value = "".join(test_len_list)
25 page = MainPage(browser, link)
26
27 #check if internet connection is present
28 if not has_connection(page.browser):
29 print('No Internet connection, aborted!')
30 page.browser.quit()
31 else:
32 page.open()
33
34 log_in_btn = page.browser.find_element_by_css_selector("button[class='header__button ng-star-inserted'][type='button']")
35 log_in_btn.click()
36 register_btn = page.browser.find_element_by_css_selector("a[class='auth-modal__register-link ng-star-inserted']")
37 register_btn.click()
38 # time.sleep(3)
39 username_input = page.browser.find_element_by_css_selector("input[id='registerUserName']")
40 username_input.send_keys(field_value)
41 time.sleep(3)
42 assert page.is_element_present(
43 'p[class="validation-message ng-star-inserted"]') == False, "Lenght does not satisfy the requirements"
44from .base_page import BasePage
45from selenium.webdriver.common.by import By
46from selenium.webdriver.support.ui import WebDriverWait
47from selenium.webdriver.support import expected_conditions as EC
48
49class MainPage(BasePage):
50
51 def click_alert(self):
52 main_window = self.browser.window_handles[0]
53 WebDriverWait(self.browser, 5).until(EC.alert_is_present())
54 alert = self.browser.switch_to.alert
55 alert.accept()
56 self.browser.switch_to.window(main_window)
57
58 def find_login_button(self):
59 return self.browser.find_element_by_css_selector("button[class='header__button ng-star-inserted'][type='button']")
60
61 def find_register_button(self):
62 return self.browser.find_element_by_css_selector("a[class='auth-modal__register-link ng-star-inserted']")
63
my BasePage file:
1import pytest
2import sys
3import time
4from selenium.webdriver.common.by import By
5from pages.main_page import MainPage
6
7link = "https://rozetka.com.ua/"
8test_len_list = [str(num) for num in range(0,100)]
9test_len_list = ['a' for num in range(0, 33)]
10test_len_str = "".join(test_len_list)
11
12class TestRegisterPage():
13 @pytest.mark.len
14@pytest.mark.parametrize('num', [0, 1, 2, 31, 32, 64, 128,256])
15def test_field_username_len(self, browser, num):
16 # is it functional testing if I need to make a sequence of steps before reaching to the element I need to test
17 # Because if some step from this sequence won't work the entire test fails
18
19 if num <= 0:
20 field_value = ''
21 else:
22 test_len_list = ['в' for b in range(0,
23 num)]
24 field_value = "".join(test_len_list)
25 page = MainPage(browser, link)
26
27 #check if internet connection is present
28 if not has_connection(page.browser):
29 print('No Internet connection, aborted!')
30 page.browser.quit()
31 else:
32 page.open()
33
34 log_in_btn = page.browser.find_element_by_css_selector("button[class='header__button ng-star-inserted'][type='button']")
35 log_in_btn.click()
36 register_btn = page.browser.find_element_by_css_selector("a[class='auth-modal__register-link ng-star-inserted']")
37 register_btn.click()
38 # time.sleep(3)
39 username_input = page.browser.find_element_by_css_selector("input[id='registerUserName']")
40 username_input.send_keys(field_value)
41 time.sleep(3)
42 assert page.is_element_present(
43 'p[class="validation-message ng-star-inserted"]') == False, "Lenght does not satisfy the requirements"
44from .base_page import BasePage
45from selenium.webdriver.common.by import By
46from selenium.webdriver.support.ui import WebDriverWait
47from selenium.webdriver.support import expected_conditions as EC
48
49class MainPage(BasePage):
50
51 def click_alert(self):
52 main_window = self.browser.window_handles[0]
53 WebDriverWait(self.browser, 5).until(EC.alert_is_present())
54 alert = self.browser.switch_to.alert
55 alert.accept()
56 self.browser.switch_to.window(main_window)
57
58 def find_login_button(self):
59 return self.browser.find_element_by_css_selector("button[class='header__button ng-star-inserted'][type='button']")
60
61 def find_register_button(self):
62 return self.browser.find_element_by_css_selector("a[class='auth-modal__register-link ng-star-inserted']")
63from selenium.common.exceptions import NoSuchElementException
64
65
66class BasePage:
67 def __init__(self, browser, url, timeout=30):
68 self.browser = browser
69 self.url = url
70 self.browser.implicitly_wait(timeout)
71
72 def open(self):
73 self.browser.get(self.url)
74
75 def is_element_present(self, css_selector):
76 try:
77 self.browser.find_element_by_css_selector(css_selector)
78 except NoSuchElementException:
79 return False
80 return True
81
Screenshot of test result for a value '31' which is of type int test case param 31
ANSWER
Answered 2021-Jul-01 at 08:52Have you tried using JS click?
1import pytest
2import sys
3import time
4from selenium.webdriver.common.by import By
5from pages.main_page import MainPage
6
7link = "https://rozetka.com.ua/"
8test_len_list = [str(num) for num in range(0,100)]
9test_len_list = ['a' for num in range(0, 33)]
10test_len_str = "".join(test_len_list)
11
12class TestRegisterPage():
13 @pytest.mark.len
14@pytest.mark.parametrize('num', [0, 1, 2, 31, 32, 64, 128,256])
15def test_field_username_len(self, browser, num):
16 # is it functional testing if I need to make a sequence of steps before reaching to the element I need to test
17 # Because if some step from this sequence won't work the entire test fails
18
19 if num <= 0:
20 field_value = ''
21 else:
22 test_len_list = ['в' for b in range(0,
23 num)]
24 field_value = "".join(test_len_list)
25 page = MainPage(browser, link)
26
27 #check if internet connection is present
28 if not has_connection(page.browser):
29 print('No Internet connection, aborted!')
30 page.browser.quit()
31 else:
32 page.open()
33
34 log_in_btn = page.browser.find_element_by_css_selector("button[class='header__button ng-star-inserted'][type='button']")
35 log_in_btn.click()
36 register_btn = page.browser.find_element_by_css_selector("a[class='auth-modal__register-link ng-star-inserted']")
37 register_btn.click()
38 # time.sleep(3)
39 username_input = page.browser.find_element_by_css_selector("input[id='registerUserName']")
40 username_input.send_keys(field_value)
41 time.sleep(3)
42 assert page.is_element_present(
43 'p[class="validation-message ng-star-inserted"]') == False, "Lenght does not satisfy the requirements"
44from .base_page import BasePage
45from selenium.webdriver.common.by import By
46from selenium.webdriver.support.ui import WebDriverWait
47from selenium.webdriver.support import expected_conditions as EC
48
49class MainPage(BasePage):
50
51 def click_alert(self):
52 main_window = self.browser.window_handles[0]
53 WebDriverWait(self.browser, 5).until(EC.alert_is_present())
54 alert = self.browser.switch_to.alert
55 alert.accept()
56 self.browser.switch_to.window(main_window)
57
58 def find_login_button(self):
59 return self.browser.find_element_by_css_selector("button[class='header__button ng-star-inserted'][type='button']")
60
61 def find_register_button(self):
62 return self.browser.find_element_by_css_selector("a[class='auth-modal__register-link ng-star-inserted']")
63from selenium.common.exceptions import NoSuchElementException
64
65
66class BasePage:
67 def __init__(self, browser, url, timeout=30):
68 self.browser = browser
69 self.url = url
70 self.browser.implicitly_wait(timeout)
71
72 def open(self):
73 self.browser.get(self.url)
74
75 def is_element_present(self, css_selector):
76 try:
77 self.browser.find_element_by_css_selector(css_selector)
78 except NoSuchElementException:
79 return False
80 return True
81element = driver.find_element_by_id("myid")
82driver.execute_script("arguments[0].click();", element)
83
Replace your click function with the above and try.
1import pytest
2import sys
3import time
4from selenium.webdriver.common.by import By
5from pages.main_page import MainPage
6
7link = "https://rozetka.com.ua/"
8test_len_list = [str(num) for num in range(0,100)]
9test_len_list = ['a' for num in range(0, 33)]
10test_len_str = "".join(test_len_list)
11
12class TestRegisterPage():
13 @pytest.mark.len
14@pytest.mark.parametrize('num', [0, 1, 2, 31, 32, 64, 128,256])
15def test_field_username_len(self, browser, num):
16 # is it functional testing if I need to make a sequence of steps before reaching to the element I need to test
17 # Because if some step from this sequence won't work the entire test fails
18
19 if num <= 0:
20 field_value = ''
21 else:
22 test_len_list = ['в' for b in range(0,
23 num)]
24 field_value = "".join(test_len_list)
25 page = MainPage(browser, link)
26
27 #check if internet connection is present
28 if not has_connection(page.browser):
29 print('No Internet connection, aborted!')
30 page.browser.quit()
31 else:
32 page.open()
33
34 log_in_btn = page.browser.find_element_by_css_selector("button[class='header__button ng-star-inserted'][type='button']")
35 log_in_btn.click()
36 register_btn = page.browser.find_element_by_css_selector("a[class='auth-modal__register-link ng-star-inserted']")
37 register_btn.click()
38 # time.sleep(3)
39 username_input = page.browser.find_element_by_css_selector("input[id='registerUserName']")
40 username_input.send_keys(field_value)
41 time.sleep(3)
42 assert page.is_element_present(
43 'p[class="validation-message ng-star-inserted"]') == False, "Lenght does not satisfy the requirements"
44from .base_page import BasePage
45from selenium.webdriver.common.by import By
46from selenium.webdriver.support.ui import WebDriverWait
47from selenium.webdriver.support import expected_conditions as EC
48
49class MainPage(BasePage):
50
51 def click_alert(self):
52 main_window = self.browser.window_handles[0]
53 WebDriverWait(self.browser, 5).until(EC.alert_is_present())
54 alert = self.browser.switch_to.alert
55 alert.accept()
56 self.browser.switch_to.window(main_window)
57
58 def find_login_button(self):
59 return self.browser.find_element_by_css_selector("button[class='header__button ng-star-inserted'][type='button']")
60
61 def find_register_button(self):
62 return self.browser.find_element_by_css_selector("a[class='auth-modal__register-link ng-star-inserted']")
63from selenium.common.exceptions import NoSuchElementException
64
65
66class BasePage:
67 def __init__(self, browser, url, timeout=30):
68 self.browser = browser
69 self.url = url
70 self.browser.implicitly_wait(timeout)
71
72 def open(self):
73 self.browser.get(self.url)
74
75 def is_element_present(self, css_selector):
76 try:
77 self.browser.find_element_by_css_selector(css_selector)
78 except NoSuchElementException:
79 return False
80 return True
81element = driver.find_element_by_id("myid")
82driver.execute_script("arguments[0].click();", element)
83log_in_btn = page.browser.find_element_by_css_selector("button[class='header__button ng-star-inserted'][type='button']")
84driver.execute_script("arguments[0].click();", log_in_btn )
85
86register_btn = page.browser.find_element_by_css_selector("a[class='auth-modal__register-link ng-star-inserted']")
87driver.execute_script("arguments[0].click();", register_btn)
88
QUESTION
Should contract testing be avoided for message queues where we're sending data packets (not requests)?
Asked 2021-May-05 at 02:10It seems contract testing doesn't yield any benefits for message queues. Does it have any benefits?
At the provider side we instantiate an object that normally goes into kafka.
So what the provider essentially does is this:
- a data object instance (in memory)
- serialized (by kafka libraries)
- serialized and used for Pact contract verification.
At the consumer side, we have have the opposite of this, i.e., we recreate that object in memory and trigger the code that consumes it.
In other words, what the consumer essentially does is:
- read packet from kafka queue (in this case Pact's mock queue)
- deserialize the object into an object instance
- try to trigger code which consumes the object.
In my case on the consumer side the code which consumes the object cannot be triggered. This is because it requires starting an instance of the server itself which introduces a lot of complexity.
Should contract testing be avoided for message queues when we're sending data packets (not requests)?
It is important to keep in mind that Contract Testing =|= Functional Testing. So we're not going to retest with different messages because that would be functional testing.
ANSWER
Answered 2021-May-05 at 02:02A contract test asks "are these services able to communicate with each other". This question is absolutely valuable for message queues.
Is it safe to deploy a new version of your consumer? It depends on whether the producer is able to read and understand the messages the provider is sending. Contract testing improves your confidence that the consumer and provider are able to speak to each other.
You could argue that contract testing is more important with message queues, because (depending on the design and how long messages live in queues/whether they are replayed), you might be consuming messages that were produced by several different versions of the producer.
Even if the consumer and provider are in the same deployment unit (eg, a single microservice), then you're likely to be consuming messages from the previous version of the provider immediately after a deployment happens.
TheorySpeaking theoretically, contract testing a message queue is like contract testing an HTTP request/response pair where the request is implicit (you could argue the "request" is the subscription to the queue).
PracticeWhen testing/verifying an HTTP Pact contract, Pact provides both the transport (mock HTTP client/server), and the content (content shape and constraints).
At the moment, when doing the same test with a Message Pact, Pact only provides the content / constraints. There's no mock consumer/provider - the data transport is not tested by the Pact framework. This means that a message pact test has slightly less coverage than the corresponding HTTP pact would - it's not testing that your queue library is set up and invoked correctly (unless you do that testing yourself).
The Pact Spec V4 Plugin proposal exists to make it easier to address this gap in the future, so that a message pact test will be able to more easily cover the queue libraries too. But, it's not something that is available to use today.
Your specific caseit requires starting an instance of the server itself which introduces a lot of complexity.
This feels like it might be a software design issue that a bit of refactoring would be able to solve. You should be able to run message pact consumer tests without starting the whole server. This will be specific to your usecase and design, but join us in #general
on https://slack.pact.io/ and we can probably help you.
It is important to keep in mind that Contract Testing =|= Functional Testing. So we're not going to retest with different messages because that would be functional testing.
Yes, this is a good observation. In general, you want to test that your consumer can understand every type of message that the provider can send, and in the case of message queues, this is usually only one type (although it is still sometimes a few).
It's a little off the topic of your question, but there's a small caveat here in that although a Pact test is not a functional test, it is ok if it has some functional coverage. All testing is risk reduction - and the closer you can get to testing the actual code you will be running, the better the risk is reduced. For this reason, I usually put any mocks as deep in the service as is practical. Of course, I would cover the behaviour of the service with its own unit tests, but I think it's good if the pact test (which doesn't cover the behaviour directly) happens to still exercise some of the behaviour in the course of contract verification. Happy to elaborate on that if you need.
QUESTION
Troubleshoot failing NUnit Selenium tests in Azure DevOps
Asked 2021-Apr-08 at 03:31I am trying to build an NUnit Selenium test suite, that I can run from within Azure DevOps, to perform functional testing on my companies web app.
I've built and testing a demo project locally, which creates a browser instance and authenticates the session with the web app in the OneTimeSetUp - the browser instance is then used to run a demo test. Where I encounter my primary issue is that when I run this test in DevOps, it fails during the OneTimeSetUp, and as such, it fails the test also.
I'm unsure how to resolve this, because as mentioned, locally, the test runs as desired. I'm running the tests against the same web app.
A secondary issue I've encountered with this is that I've tried taking screenshots using the ((ITakesScreenshot)driver).GetScreenshot() method, so that I might be able to see where the test is having trouble, but no screenshots appear in the test results (where I understand they should appear (based off this video))
Without being able to see what the tests are doing in DevOps, I'm at a loss as to how to troubleshoot this issue. Any tips, pointers, or resources on how to achieve this are greatly appreciated.
ANSWER
Answered 2021-Apr-08 at 03:31Troubleshoot failing NUnit Selenium tests in Azure DevOps
Based on your description, you are creates a browser instance and authenticates the session with the web app in the OneTimeSetUp - the browser instance is then used to run a demo test, it shows you are running UI tests.
So, you should make sure run your self-hosted agent as an interactive mode and a special configuration of the agents is required.
Please check the detailed info from the documents UI testing considerations.
QUESTION
how to run a node.js github repository as a service in another repository on github actions
Asked 2021-Jan-03 at 13:33So I have a project that needs a "fake" API to do some functional testing on user scenarios; so my idea was creating a simple little node.js project and getting to return some dummy json data depending on a few endpoints to test several use cases of my application.
I have a separate repository containing this fake API and I'm wondering how I should go about adding it into my github actions workflow?
ANSWER
Answered 2021-Jan-03 at 13:33You can use actions/checkout@v2
to pull another repo into your worker.
See the example below:
1name: PullExternalRepo
2
3on: workflow_dispatch
4
5jobs:
6 PullRepo:
7 runs-on: ubuntu-latest
8 - name: Install Node
9 uses: actions/setup-node@v2-beta
10 with:
11 node-version: '12'
12 - name: Install external repo
13 uses: actions/checkout@v2
14 with:
15 repository: your_org/repo_name
16 path: './place/to/clone/repo/into'
17 - name: Install deps and run
18 run: |
19 cd ./place/to/clone/repo/into
20 npm install
21 npm start
22
23
Added note about pulling specific branches:
If you are trying to pull a non-default branch, you need to add the ref
property to the checkout action, as seen in the example below.
1name: PullExternalRepo
2
3on: workflow_dispatch
4
5jobs:
6 PullRepo:
7 runs-on: ubuntu-latest
8 - name: Install Node
9 uses: actions/setup-node@v2-beta
10 with:
11 node-version: '12'
12 - name: Install external repo
13 uses: actions/checkout@v2
14 with:
15 repository: your_org/repo_name
16 path: './place/to/clone/repo/into'
17 - name: Install deps and run
18 run: |
19 cd ./place/to/clone/repo/into
20 npm install
21 npm start
22
23...
24 - name: Install external repo
25 uses: actions/checkout@v2
26 with:
27 repository: your_org/repo_name
28 path: './place/to/clone/repo/into'
29 ref: 'some-other-branch'
30...
31
QUESTION
How to access spark history server
Asked 2020-Nov-25 at 14:11I am running my spark application on small dataset just for functional testing. But I also wanted to see how many the executors are being created and how the data is being partitioned. For this, I tried to access the spark UI application but the problem with accessing spark UI application is that the connection is lost as soon as the application completes.
How to access the spark history server to monitor past spark applications. I am running the spark application using intellij IDE and I am not able to find the option to access such server.
ANSWER
Answered 2020-Aug-04 at 17:08How about adding a sleep call at the end of the program to delay its completion?
QUESTION
How can you programmatically raise a conditional PR?
Asked 2020-Oct-21 at 10:05We currently have the following branch strategy:
Develop > Release > Master
Devs create a local branch from Develop, make changes merge to develop. Our dev environment builds off that branch. When they want their changes tested they push to QA environment, which also uses the Develop branch. This cycle goes on until functional testing for the iteration is done. At that point the code is merged into the Release branch and is deployed through staging and then to prod. After deploying to prod the code should be merged to Master, but it's often forgotten about. This causes problems in niche scenarios.
Is there a way to use perhaps devops pipelines to conditionally raise a PR automatically? So I'm thinking this would need 2 PRs:
- PR raised for Master branch after successful release to prod. Idea here would be once sign off has been granted someone from the team can just approve.
- PR raised for Develop branch if the first PR is approved and the code in Master now differs from Develop. In a lot of cases it won't as therefore wouldn't need a PR.
I've been googling for this and found the api methods like this but I can't see how you could put this in a pipeline and make it conditional.
Additional Info:
My understanding is that the build definition needs to know what branch to build as per the image below. So, creating a new release branch every sprint would either result in having to update the build definition every time or creating a new build definition, that essentially would be a complete replica in most cases except for the branch name. Unless I'm misunderstanding, which I think I am.
ANSWER
Answered 2020-Sep-11 at 11:31The following PowerShell example creates a pull request from master to some target branch as a build task. You can add it to your release as an additional stage "Create PR to some branch" with one PowerShell task. Additionally, you can create periodically build to check diff and create pull requests.
1$user = ""
2$token = "$(System.AccessToken)"
3$branchTarget = "$(Build.SourceBranch)"
4$branchSource = "refs/heads/master"
5$branchTragetPath = $branchTarget -replace "refs/heads/", ""
6$teamProject = "$(System.TeamProject)"
7$repoName = "$(Build.Repository.Name)"
8$orgUrl = "$(System.CollectionUri)"
9
10$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user,$token)))
11
12$uriBranchStatus = "$orgUrl/$teamProject/_apis/git/repositories/$repoName/stats/branches?name=$branchTragetPath&api-version=5.1"
13$uriCheckActivePR = "$orgUrl/$teamProject/_apis/git/repositories/$repoName/pullrequests?searchCriteria.targetRefName=$branchTarget&searchCriteria.sourceRefName=$branchSource&api-version=5.1"
14$uriCreatePR = "$orgUrl/$teamProject/_apis/git/repositories/$repoName/pullrequests?api-version=5.1"
15
16$resultStatus = Invoke-RestMethod -Uri $uriBranchStatus -Method Get -ContentType "application/json" -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)}
17
18if ($resultStatus.behindCount -eq 0)
19{
20 Write-Host "Current branch contains last changes from master"
21 Return
22}
23
24$resultActivePR = Invoke-RestMethod -Uri $uriCheckActivePR -Method Get -ContentType "application/json" -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)}
25
26if ($resultActivePR.count -gt 0)
27{
28 Write-Host "PR exists already"
29 Return
30}
31
32$bodyCreatePR = "{sourceRefName:'$branchSource',targetRefName:'$branchTarget',title:'Sync changes from $branchSource'}"
33
34$result = Invoke-RestMethod -Uri $uriCreatePR -Method Post -ContentType "application/json" -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -Body $bodyCreatePR
35
36Write-Host "Created PR" $result.pullRequestId
37
Community Discussions contain sources that include Stack Exchange Network
Tutorials and Learning Resources in Functional Testing
Tutorials and Learning Resources are not available at this moment for Functional Testing