Skip to content
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

[plugin-web-app] Add mobile emulation steps #4656

Merged
merged 1 commit into from
Dec 12, 2023

Conversation

uarlouski
Copy link
Member

No description provided.

@uarlouski uarlouski requested a review from a team as a code owner December 11, 2023 08:50
@@ -1353,6 +1353,45 @@ Then value `$value` is selected in slider located by `$locator`
Then value `50` is selected in slider located by `id(test_slider)`
----

=== Emulation steps
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
=== Emulation steps
=== Mobile Emulation


==== Override device metrics

Overrides the values of device screen dimensions.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which browsers are supported?
what is an effect of this step execution?

the same for the step clearing metrics

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It turns out these steps are supported only on chrome browser, for other browsers:

  • non-chromium browser like safari: class case exception during augumentation
  • chromium browsers: Exception in thread "main" org.openqa.selenium.UnsupportedCommandException: unknown command: unknown command: session/6f209346788418b9ce82c8619162e1df/goog/cdp/execute


[source,gherkin]
----
When I override device metrics:`$deviceMetrics`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
When I override device metrics:`$deviceMetrics`
When I configure mobile device emulation:`$deviceMetrics`


[source,gherkin]
----
When I clear device metrics
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
When I clear device metrics
When I clear configuration of mobile device emulation

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

too cumbersome

import org.vividus.selenium.IWebDriverProvider;
import org.vividus.util.json.JsonUtils;

public class EmulationSteps
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public class EmulationSteps
public class MobileEmulationSteps


private void executeCdpCommand(String command, Map<String, Object> metrics)
{
HasCdp hasCdp = webDriverProvider.getUnwrapped(HasCdp.class);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if this interface is not implemented? what will the error be?

Copy link

github-actions bot commented Dec 11, 2023

Qodana Community for JVM

It seems all right 👌

No new problems were found according to the checks applied

💡 Qodana analysis was run in the pull request mode: only the changed files were checked
☁️ View the detailed Qodana report

Contact Qodana team

Contact us at [email protected]

Copy link

codecov bot commented Dec 11, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (4b450cf) 89.13% compared to head (bf52d02) 97.39%.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #4656      +/-   ##
============================================
+ Coverage     89.13%   97.39%   +8.25%     
- Complexity     6778     6782       +4     
============================================
  Files           914      915       +1     
  Lines         18819    18832      +13     
  Branches       1253     1253              
============================================
+ Hits          16774    18341    +1567     
+ Misses         1917      384    -1533     
+ Partials        128      107      -21     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@uarlouski uarlouski force-pushed the feature/mobile-emulation branch 2 times, most recently from acd6de7 to dce419c Compare December 11, 2023 13:56

==== Emulate mobile device

Emulates mobile device using provided configuration.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Emulates mobile device using provided configuration.
Emulates mobile device using the provided configuration.

When I emulate mobile device with configuration:`$deviceMetrics`
----

* `$deviceMetrics` - The JSON containing device metrics to override, please see https://chromedevtools.github.io/devtools-protocol/tot/Emulation/#method-setDeviceMetricsOverride[available metrics].
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* `$deviceMetrics` - The JSON containing device metrics to override, please see https://chromedevtools.github.io/devtools-protocol/tot/Emulation/#method-setDeviceMetricsOverride[available metrics].
* `$deviceMetrics` - The JSON containing https://chromedevtools.github.io/devtools-protocol/tot/Emulation/#method-setDeviceMetricsOverride[device metrics] to override.


==== Reset mobile device emulation

Resets the mobile device emulation returning browser screen to its initial state.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Resets the mobile device emulation returning browser screen to its initial state.
Resets the mobile device emulation returning the browser to its initial state.

When I reset mobile device emulation
----

.Clears device metrics to default
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.Clears device metrics to default
.Resets device metrics to defaults

* Emulates mobile device using provided configuration.
*
* <p>
* <strong>The step is only supported in Chrome browser.</strong>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* <strong>The step is only supported in Chrome browser.</strong>
* <strong>The step is only supported by Chrome browser.</strong>

?

@When("I reset mobile device emulation")
public void clearDeviceMetrics()
{
executeCdpCommand("Emulation.clearDeviceMetricsOverride", Map.of());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if the browser was started in mobile emulation mode?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will reset the mobile emulation, even if we have mobile emulation profile activated, technically the initial state of the browser doesn't include mobile emulation, its turned on after the browser is loaded

Copy link

sonarcloud bot commented Dec 12, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@valfirst valfirst merged commit 031293b into master Dec 12, 2023
11 checks passed
@valfirst valfirst deleted the feature/mobile-emulation branch December 12, 2023 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants