-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #120 from 2gis/get-element-attribute-settings
Add settings for GetElementAttribute command
- Loading branch information
Showing
14 changed files
with
291 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
Winium/TestApp.Test/py-functional/tests/test_element_attribute_settings.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# coding: utf-8 | ||
from copy import copy | ||
|
||
import pytest | ||
from selenium.webdriver import Remote | ||
|
||
import config | ||
|
||
|
||
@pytest.yield_fixture() | ||
def driver(request): | ||
capabilities = request.param | ||
winium = Remote(command_executor="http://localhost:9999", desired_capabilities=capabilities) | ||
yield winium | ||
winium.quit() | ||
|
||
|
||
def _enum_as_string_settings_capability(value): | ||
caps = copy(config.DESIRED_CAPABILITIES) | ||
caps['commandSettings'] = {'elementAttributeSettings': {'enumAsString': value}} | ||
return caps | ||
|
||
|
||
def _access_modifier_settings_capability(value): | ||
caps = copy(config.DESIRED_CAPABILITIES) | ||
caps['commandSettings'] = {'elementAttributeSettings': {'accessModifier': value}} | ||
return caps | ||
|
||
|
||
class TestElementAttributeCommandSettings(object): | ||
@pytest.mark.parametrize('driver', [_enum_as_string_settings_capability(False)], indirect=True) | ||
def test_get_element_attribute_enum_as_value(self, driver): | ||
element = driver.find_element_by_id('MyTextBox') | ||
element.get_attribute('DesiredSize') | ||
value = element.get_attribute('Visibility') | ||
assert '0' == value | ||
|
||
@pytest.mark.parametrize('driver', [_enum_as_string_settings_capability(True)], indirect=True) | ||
def test_get_element_attribute_enum_as_string(self, driver): | ||
element = driver.find_element_by_id('MyTextBox') | ||
value = element.get_attribute('Visibility') | ||
assert 'Visible' == value | ||
|
||
@pytest.mark.parametrize('driver', [ | ||
_access_modifier_settings_capability('AutomationProperties'), | ||
_access_modifier_settings_capability('DependencyProperties'), | ||
_access_modifier_settings_capability('ClrProperties'), | ||
], indirect=True) | ||
def test_get_element_attribute_access_modifier(self, driver): | ||
expected = { | ||
'AutomationProperties': ['MyTextBox', None, None], | ||
'DependencyProperties': ['MyTextBox', 'false', None], | ||
'ClrProperties': ['MyTextBox', 'false', '300'], | ||
}[driver.desired_capabilities['commandSettings']['elementAttributeSettings']['accessModifier']] | ||
|
||
element = driver.find_element_by_id('MyTextBox') | ||
|
||
for i, attr in enumerate(['AutomationIdProperty', 'IsReadOnlyProperty', 'Width']): | ||
value = element.get_attribute(attr) | ||
assert expected[i] == value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
Winium/Winium.StoreApps.Common/CommandSettings/CommandSettings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
namespace Winium.StoreApps.Common.CommandSettings | ||
{ | ||
#region | ||
|
||
using Newtonsoft.Json; | ||
|
||
#endregion | ||
|
||
public class CommandSettings | ||
{ | ||
#region Constants | ||
|
||
public const string ElementAttributeSettingsParameter = "ElementAttributeSettings"; | ||
|
||
#endregion | ||
|
||
#region Constructors and Destructors | ||
|
||
public CommandSettings() | ||
{ | ||
this.ElementAttributeSettings = new ElementAttributeCommandSettings(); | ||
} | ||
|
||
#endregion | ||
|
||
#region Public Properties | ||
|
||
[JsonProperty("elementAttributeSettings")] | ||
public ElementAttributeCommandSettings ElementAttributeSettings { get; set; } | ||
|
||
#endregion | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
Winium/Winium.StoreApps.Common/CommandSettings/ElementAttributeCommandSettings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
namespace Winium.StoreApps.Common.CommandSettings | ||
{ | ||
#region | ||
|
||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Converters; | ||
|
||
#endregion | ||
|
||
public enum ElementAttributeAccessModifier | ||
{ | ||
None = 0, | ||
|
||
AutomationProperties = 1, | ||
|
||
DependencyProperties = 3, | ||
|
||
ClrProperties = 7, | ||
} | ||
|
||
public class ElementAttributeCommandSettings | ||
{ | ||
#region Constructors and Destructors | ||
|
||
public ElementAttributeCommandSettings() | ||
{ | ||
this.AccessModifier = ElementAttributeAccessModifier.ClrProperties; | ||
this.EnumAsString = false; | ||
} | ||
|
||
#endregion | ||
|
||
#region Public Properties | ||
|
||
[JsonProperty("accessModifier")] | ||
[JsonConverter(typeof(StringEnumConverter))] | ||
public ElementAttributeAccessModifier AccessModifier { get; set; } | ||
|
||
[JsonProperty("enumAsString")] | ||
public bool EnumAsString { get; set; } | ||
|
||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
Winium/Winium.StoreApps.Driver/CommandExecutors/GetElementAttributeExecutor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
namespace Winium.StoreApps.Driver.CommandExecutors | ||
{ | ||
#region | ||
|
||
using Newtonsoft.Json.Linq; | ||
|
||
using Winium.StoreApps.Common.CommandSettings; | ||
|
||
#endregion | ||
|
||
internal class GetElementAttributeExecutor : CommandExecutorBase | ||
{ | ||
#region Methods | ||
|
||
protected override string DoImpl() | ||
{ | ||
var settings = JToken.FromObject(this.Automator.ActualCapabilities.CommandSettings.ElementAttributeSettings); | ||
this.ExecutedCommand.Parameters.Add(CommandSettings.ElementAttributeSettingsParameter, settings); | ||
var response = this.Automator.CommandForwarder.ForwardCommand(this.ExecutedCommand); | ||
|
||
return response; | ||
} | ||
|
||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.