8000 [extension-selenium] Move attribute filter into common module by uarlouski · Pull Request #3918 · vividus-framework/vividus · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[extension-selenium] Move attribute filter into common module #3918

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/modules/plugins/partials/plugin-web-app-locators.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ The elements not matching the filter condition are sorted out without any notice

include::partial$common-filters.adoc[]

|`attribute`
|Filter elements by their attribute values
a|`tagName(div)->filter.attribute(class=burger-menu)` - `div` element has the `class` attribute with `burger-menu` value
`tagName(div)->filter.attribute(class)` - `div` element has the `class` attribute with any value
`tagName(div)->filter.attribute(class=)` - `div` element has the `class` attribute with an empty value

|`state`
|element xref:parameters:state.adoc[State]
|id(v1)->filter.state(VISIBLE)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2020 the original author or authors.
* Copyright 2019-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,20 +14,18 @@
* limitations under the License.
*/

package org.vividus.ui.mobile.action.search;
package org.vividus.ui.action.search;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Validate;
import org.openqa.selenium.WebElement;
import org.vividus.ui.action.search.IElementFilterAction;
import org.vividus.ui.action.search.LocatorType;

public class ElementAttributeFilter implements IElementFilterAction
{
@Override
public LocatorType getType()
{
return AppiumLocatorType.ATTRIBUTE;
return GenericLocatorType.ATTRIBUTE;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2020 the original author or authors.
* Copyright 2019-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,7 +18,8 @@

public enum GenericLocatorType implements LocatorType
{
INDEX("Index", IndexElementFilter.class);
INDEX("Index", IndexElementFilter.class),
ATTRIBUTE("Attribute", ElementAttributeFilter.class);

private final String attributeName;
private final Class<? extends IElementAction> actionClass;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@
<bean id="barcodeSteps" class="org.vividus.steps.ui.BarcodeSteps" />

<bean class="org.vividus.ui.action.search.IndexElementFilter" />
<bean class="org.vividus.ui.action.search.ElementAttributeFilter" />

<bean class="org.vividus.selenium.screenshot.AbstractScreenshotTaker" id="abstractScreenshotTaker" abstract="true" />

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2020 the original author or authors.
* Copyright 2019-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,7 +14,7 @@
* limitations under the License.
*/

package org.vividus.ui.mobile.action.search;
package org.vividus.ui.action.search;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
Expand Down Expand Up @@ -81,6 +81,6 @@ void shouldNotFilterIfValueIsEmpty()
@Test
void shouldReturnLocatorType()
{
assertEquals(AppiumLocatorType.ATTRIBUTE, filter.getType());
assertEquals(GenericLocatorType.ATTRIBUTE, filter.getType());
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 the original author or authors.
* Copyright 2019-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -67,8 +67,7 @@ public By buildBy(String value)
}
},
TEXT_PART("Text part", GenericTextFilter.class),
TEXT("Text", GenericTextFilter.class),
ATTRIBUTE("Attribute", ElementAttributeFilter.class);
TEXT("Text", GenericTextFilter.class);

private final String attributeName;
private final Class<? extends IElementAction> actionClass;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@
<constructor-arg index="1" value="#{T(org.vividus.steps.StringComparisonRule).IS_EQUAL_TO}" />
</bean>

<bean class="org.vividus.ui.mobile.action.search.ElementAttributeFilter" />

<bean class="org.vividus.ui.mobile.action.MobileAppElementActions" />

<bean class="org.vividus.selenium.mobileapp.screenshot.MobileAppAshotFactory" parent="abstractAshotFactory">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 the original author or authors.
* Copyright 2019-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -46,7 +46,7 @@ void shouldBuildBy(String prefix, AppiumLocatorType locatorType)
}

@ParameterizedTest
@EnumSource(names = { "TEXT_PART", "TEXT", "ATTRIBUTE" })
@EnumSource(names = { "TEXT_PART", "TEXT" })
void shouldNotBuildBy(AppiumLocatorType locatorType)
{
assertThrows(UnsupportedOperationException.class, () -> locatorType.buildBy(VALUE));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ Given I am on page with URL `${vividus-test-site-url}/checkboxes.html`
Then number of elements found by `checkboxName(One)` is equal to `1`


Scenario: Verify tagName(...) search attribute and index(...) filter
Scenario: Verify tagName(...) search attribute and index(...) filter and attribute(...) filter
Given I am on page with URL `${vividus-test-site-url}/elementState.html`
When I save `id` attribute value of element located `tagName(button)->filter.index(2)` to SCENARIO variable `elementId`
Then `${elementId}` is equal to `button-show`
When I save `id` attribute value of element located `tagName(button)->filter.attribute(id=button-show)` to SCENARIO variable `elementId`
Then `${elementId}` is equal to `button-show`
0