Injecting CSS into site with Puppeteer

addStyleTag: You can use page.addStyleTag to add some style which will either add a link or style tag based on your options which can be a url, path or some css content. // url await page.addStyleTag({url: ‘http://example.com/style.css’}) // path, can be relative or absolute path await page.addStyleTag({path: ‘style.css’}) // content await page.addStyleTag({content: ‘.body{background: red}’}) evaluateOnNewDocument: … Read more

Is the .should(‘exist’) assertion redundant on Cypress?

For your usecase of asserting whether an element exists, they are indeed redundant. .contains() yields a DOM element and according to documentation, .should yields the same element it was given as an input. There are some exceptions when .should yields different element (as you can see in the documentation) but in case of using should(‘exist’), … Read more

Running Selenium scripts with JMeter

Below are possible ways to run Selenium test-cases from JMeter: using JUnit Request Sampler; using BeanShell Sampler; using JSR223 Sampler + Groovy. JUnit Request Sampler Running Selenium tests this way maybe useful if you want to re-use already automated (Java) Selenium scenarios instead of re-writing JS-scripts for WebDriver Sampler. Selenium RC Prepare Selenium test project … Read more

How to stop all tests from inside a test or setUp using unittest?

In case you are interested, here is a simple example how you could make a decision yourself about exiting a test suite cleanly with py.test: # content of test_module.py import pytest counter = 0 def setup_function(func): global counter counter += 1 if counter >=3: pytest.exit(“decided to stop the test run”) def test_one(): pass def test_two(): … Read more

TestNG dependsOnMethods from different class

Put the method in a group and use dependsOnGroups. class c1 { @Test(groups={“c1.verifyConfig”}) public void verifyConfig() { //verify some test config parameters } } class c2 { @Test(dependsOnGroups={“c1.verifyConfig”}) public void dotest() { //Actual test } } It is recommended to verify configuration in a @Before* and throw if something goes wrong there so the tests … Read more