Multiple variables in one single Response Assertion pattern
Question:
I want to assert multiple variables in one single Response Assertion
pattern. A method exists to verify an OR of multiple values, but i
haven't found one for AND.
For example, to assert values v1, v2, or v3 - you could add in the
I need something that gives me the same flexibility with an AND condition. I'm currently having to add one pattern for each value I want to assert, and this is extremely painful to do, especially with a long assertion list.
Does anyone know of a way to combine assertion patterns using some kind of an AND operator? I have tried obvious ones,
Answer 1:
Answer 2:
For example, to assert values v1, v2, or v3 - you could add in the
Response Assertion > Patterns to Test >Add : v1|v2|v31
. The test will pass if any one of them is found in the response. This also works with the ||
operator. I need something that gives me the same flexibility with an AND condition. I'm currently having to add one pattern for each value I want to assert, and this is extremely painful to do, especially with a long assertion list.
Does anyone know of a way to combine assertion patterns using some kind of an AND operator? I have tried obvious ones,
&
, &&
, .
, +
,etc. but no luck thus far.Answer 1:
I thinks that Beanshell Assertion is that what you're looking for, it gives as much flexibility as you can think of.
Example AND -based assertion code will look like:
You can refer to How to use BeanShell: JMeter's favorite built-in component guide for more detailed explanation and kind of cookbook. |
Answer 2:
When you add multiple lines to the Response Assertion the default operation is to AND the lines.
A separate line for each V1, V2, V3 equals V1&V2&V3.
This means you can also mix. A line for V1 and a line for V2|V3 equals V1&(V2|V3).
Example (should be tested):
A separate line for each V1, V2, V3 equals V1&V2&V3.
This means you can also mix. A line for V1 and a line for V2|V3 equals V1&(V2|V3).
Example (should be tested):
@Test
public void testWithoutTestbench() {
driver.get(UIUrl);
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
List<WebElement> elements = driver.findElements(By.id("arid_WIN_3_1000000218"));
if (elements.isEmpty()) {
throw new RuntimeException("No text area found");
}
String value = elements.get(0).getAttribute("title");
Assert.assertEquals("Raushan Kumar", value);
}
Комментариев нет:
Отправить комментарий