diff --git a/dart/async/lib/html.dart b/dart/async/lib/html.dart
index 76a5a94e..c9f8210a 100644
--- a/dart/async/lib/html.dart
+++ b/dart/async/lib/html.dart
@@ -201,8 +201,12 @@ abstract class HtmlPageLoaderElement implements PageLoaderElement {
}
@override
+ @deprecated
PageLoaderAttributes get attributes => new _EmptyAttributes();
+ @override
+ PageLoaderAttributes get seleniumAttributes => new _EmptyAttributes();
+
@override
Future get isFocused async => document.activeElement == node;
@@ -249,13 +253,13 @@ abstract class HtmlPageLoaderElement implements PageLoaderElement {
class _ElementPageLoaderElement extends HtmlPageLoaderElement {
final Element node;
- final PageLoaderAttributes attributes;
+ final PageLoaderAttributes seleniumAttributes;
final PageLoaderAttributes computedStyle;
final PageLoaderAttributes style;
_ElementPageLoaderElement(Element _node, HtmlPageLoader loader)
: this.node = _node,
- this.attributes = new _ElementAttributes(_node),
+ this.seleniumAttributes = new _ElementSeleniumAttributes(_node),
this.computedStyle = new _ElementComputedStyle(_node),
this.style = new _ElementStyle(_node),
super._(loader);
@@ -271,6 +275,10 @@ class _ElementPageLoaderElement extends HtmlPageLoaderElement {
return this;
}
+ @deprecated
+ @override
+ PageLoaderAttributes get attributes => seleniumAttributes;
+
@override
Future get name async => node.tagName.toLowerCase();
// TODO(DrMarcII): implement this to recurse up the tree to see if displayed
@@ -388,7 +396,7 @@ class _DocumentPageLoaderElement extends HtmlPageLoaderElement {
}, sync);
}
-class _ElementAttributes extends PageLoaderAttributes {
+class _ElementSeleniumAttributes extends PageLoaderAttributes {
static const _BOOLEAN_ATTRIBUTES = const [
'async',
'autofocus',
@@ -435,7 +443,7 @@ class _ElementAttributes extends PageLoaderAttributes {
final Element _node;
- _ElementAttributes(this._node);
+ _ElementSeleniumAttributes(this._node);
/// Based on algorithm from:
/// https://dvcs.w3.org/hg/webdriver/raw-file/a9916dddac01/webdriver-spec.html#get-id-attribute
diff --git a/dart/async/lib/src/annotations.dart b/dart/async/lib/src/annotations.dart
index f2ef869e..43aec506 100644
--- a/dart/async/lib/src/annotations.dart
+++ b/dart/async/lib/src/annotations.dart
@@ -261,6 +261,9 @@ class IsDisplayed extends ElementFilter {
/// Keeps only [PageLoaderElement]s that have the given attribute with the
/// given value.
+///
+/// Deprecated: use WithSeleniumAttribute instead.
+@deprecated
class WithAttribute extends ElementFilter {
final String _attribute;
final String _value;
@@ -269,11 +272,29 @@ class WithAttribute extends ElementFilter {
@override
Future keep(PageLoaderElement element) async =>
- (await element.attributes[_attribute]) == _value;
+ (await element.seleniumAttributes[_attribute]) == _value;
String toString() => '@WithAttribute($_attribute, $_value)';
}
+/// Keeps only [PageLoaderElement]s that have the given attribute with the
+/// given value.
+///
+/// Note: this is primarily inteaded for transition to separate WithAttribute
+/// WithProperty Filters that differentiate between attributes/properties.
+class WithSeleniumAttribute extends ElementFilter {
+ final String _attribute;
+ final String _value;
+
+ const WithSeleniumAttribute(this._attribute, this._value);
+
+ @override
+ Future keep(PageLoaderElement element) async =>
+ (await element.seleniumAttributes[_attribute]) == _value;
+
+ String toString() => '@WithSeleniumAttribute($_attribute, $_value)';
+}
+
/// Keeps only [PageLoaderElement]s that correspond to the given tag.
class IsTag extends ElementFilter {
final String _name;
diff --git a/dart/async/lib/src/interfaces.dart b/dart/async/lib/src/interfaces.dart
index 3e6d33bb..c872a24f 100644
--- a/dart/async/lib/src/interfaces.dart
+++ b/dart/async/lib/src/interfaces.dart
@@ -84,8 +84,18 @@ abstract class PageLoaderElement {
Future get name;
/// Attributes associated with this element.
+ ///
+ /// Deprecated: Use seleniumAttributes
+ @deprecated
PageLoaderAttributes get attributes;
+ /// Attributes/properties associated with this element. This corresponds to the Selenium
+ /// WebDriver's get attribute endpoint.
+ ///
+ /// Note: this intended primarily for transition to new attributes/properties implementations
+ /// that will accurately distinguish between attributes and properties.
+ PageLoaderAttributes get seleniumAttributes;
+
/// CSS properties of this element after applying the active stylesheets and
/// resolving any basic computation, such as converting a percentage into an
/// absolute length.
diff --git a/dart/async/lib/webdriver.dart b/dart/async/lib/webdriver.dart
index 2490eb7d..02b7dca5 100644
--- a/dart/async/lib/webdriver.dart
+++ b/dart/async/lib/webdriver.dart
@@ -146,8 +146,12 @@ abstract class WebDriverPageLoaderElement implements PageLoaderElement {
String toString() => '$runtimeType<${context.toString()}>';
@override
+ @deprecated
PageLoaderAttributes get attributes => new _EmptyAttributes();
+ @override
+ PageLoaderAttributes get seleniumAttributes => new _EmptyAttributes();
+
@override
Future get isFocused async {
if (context is wd.WebElement) {
@@ -206,14 +210,14 @@ abstract class WebDriverPageLoaderElement implements PageLoaderElement {
class _WebElementPageLoaderElement extends WebDriverPageLoaderElement {
final wd.WebElement context;
- final PageLoaderAttributes attributes;
+ final PageLoaderAttributes seleniumAttributes;
final PageLoaderAttributes computedStyle;
final PageLoaderAttributes style;
_WebElementPageLoaderElement(
wd.WebElement _context, WebDriverPageLoader loader)
: this.context = _context,
- this.attributes = new _ElementAttributes(_context),
+ this.seleniumAttributes = new _ElementSeleniumAttributes(_context),
this.computedStyle = new _ElementComputedStyle(_context),
this.style = new _ElementStyle(_context),
super._(loader);
@@ -233,6 +237,10 @@ class _WebElementPageLoaderElement extends WebDriverPageLoaderElement {
@override
Future get name => context.name;
+ @override
+ @deprecated
+ PageLoaderAttributes get attributes => seleniumAttributes;
+
@override
Future get innerText async => (await context.driver
.execute('return arguments[0].textContent;', [context]))
@@ -365,10 +373,10 @@ class _ShadowRootPageLoaderElement extends WebDriverPageLoaderElement {
}
}
-class _ElementAttributes extends PageLoaderAttributes {
+class _ElementSeleniumAttributes extends PageLoaderAttributes {
final wd.WebElement _node;
- _ElementAttributes(this._node);
+ _ElementSeleniumAttributes(this._node);
@override
Future operator [](String name) => _node.attributes[name];
diff --git a/dart/async/test/src/annotations.dart b/dart/async/test/src/annotations.dart
index cdeef145..6b5340cd 100644
--- a/dart/async/test/src/annotations.dart
+++ b/dart/async/test/src/annotations.dart
@@ -36,15 +36,15 @@ void runTests() {
expect(await page.element.visibleText, 'r1c1');
});
- test('WithAttribute', () async {
- PageForWithAttributeTest page =
- await loader.getInstance(PageForWithAttributeTest);
- expect(await page.element.attributes['type'], 'checkbox');
+ test('WithSeleniumAttribute', () async {
+ PageForWithSeleniumAttributeTest page =
+ await loader.getInstance(PageForWithSeleniumAttributeTest);
+ expect(await page.element.seleniumAttributes['type'], 'checkbox');
});
test('WithClass', () async {
var page = await loader.getInstance(PageForWithClassTest);
- expect(await page.element.attributes['type'], 'checkbox');
+ expect(await page.element.seleniumAttributes['type'], 'checkbox');
expect(await page.element.classes.toList(),
unorderedEquals(['with-class-test', 'class1', 'class2']));
});
@@ -87,9 +87,9 @@ class PageForFirstByCssTest {
PageLoaderElement element;
}
-class PageForWithAttributeTest {
+class PageForWithSeleniumAttributeTest {
@ByTagName('input')
- @WithAttribute('type', 'checkbox')
+ @WithSeleniumAttribute('type', 'checkbox')
PageLoaderElement element;
}
diff --git a/dart/async/test/src/attributes.dart b/dart/async/test/src/attributes.dart
index e5d49cd3..ee92670f 100644
--- a/dart/async/test/src/attributes.dart
+++ b/dart/async/test/src/attributes.dart
@@ -33,86 +33,86 @@ void runTests() {
test('checked', () async {
var page = await loader.getInstance(PageForAttributesTests);
- expect(await page.checkbox.attributes['checked'], isNull);
+ expect(await page.checkbox.seleniumAttributes['checked'], isNull);
await page.checkbox.click();
- expect(await page.checkbox.attributes['checked'], 'true');
+ expect(await page.checkbox.seleniumAttributes['checked'], 'true');
});
test('disabled', () async {
var page = await loader.getInstance(PageForAttributesTests);
- expect(await page.readOnly.attributes['disabled'], 'true');
- expect(await page.text.attributes['disabled'], isNull);
+ expect(await page.readOnly.seleniumAttributes['disabled'], 'true');
+ expect(await page.text.seleniumAttributes['disabled'], isNull);
});
test('not a property', () async {
var page = await loader.getInstance(PageForAttributesTests);
expect(
- await page.table.attributes['non-standard'], 'a non standard attr');
+ await page.table.seleniumAttributes['non-standard'], 'a non standard attr');
});
test('option values', () async {
var page = await loader.getInstance(PageForAttributesTests);
// The expects below are according to the WebDriver spec, but currently
// fail
- // expect(page.option1.attributes['value'], 'option 1');
- // expect(page.option1.attributes['VaLuE'], 'option 1');
- expect(await page.option2.attributes['value'], 'value 2');
- expect(await page.option2.attributes['VaLuE'], 'value 2');
+ // expect(page.option1.seleniumAttributes['value'], 'option 1');
+ // expect(page.option1.seleniumAttributes['VaLuE'], 'option 1');
+ expect(await page.option2.seleniumAttributes['value'], 'value 2');
+ expect(await page.option2.seleniumAttributes['VaLuE'], 'value 2');
});
test('option selected', () async {
var page = await loader.getInstance(PageForAttributesTests);
await page.option2.click();
- expect(await page.select1.attributes['value'], equals('value 2'));
+ expect(await page.select1.seleniumAttributes['value'], equals('value 2'));
});
test('selected on checkbox', () async {
var page = await loader.getInstance(PageForAttributesTests);
- expect(await page.checkbox.attributes['selected'], isNull);
- expect(await page.checkbox.attributes['SeLeCtEd'], isNull);
+ expect(await page.checkbox.seleniumAttributes['selected'], isNull);
+ expect(await page.checkbox.seleniumAttributes['SeLeCtEd'], isNull);
await page.checkbox.click();
- expect(await page.checkbox.attributes['selected'], 'true');
- expect(await page.checkbox.attributes['SeLeCtEd'], 'true');
+ expect(await page.checkbox.seleniumAttributes['selected'], 'true');
+ expect(await page.checkbox.seleniumAttributes['SeLeCtEd'], 'true');
});
test('selected on radio', () async {
var page = await loader.getInstance(PageForAttributesTests);
- expect(await page.radio.attributes['selected'], isNull);
- expect(await page.radio.attributes['SeLeCtEd'], isNull);
+ expect(await page.radio.seleniumAttributes['selected'], isNull);
+ expect(await page.radio.seleniumAttributes['SeLeCtEd'], isNull);
await page.radio.click();
- expect(await page.radio.attributes['selected'], 'true');
- expect(await page.radio.attributes['SeLeCtEd'], 'true');
+ expect(await page.radio.seleniumAttributes['selected'], 'true');
+ expect(await page.radio.seleniumAttributes['SeLeCtEd'], 'true');
});
test('href on a', () async {
var page = await loader.getInstance(PageForAttributesTests);
- expect(await page.anchor.attributes['href'], endsWith('/test.html'));
+ expect(await page.anchor.seleniumAttributes['href'], endsWith('/test.html'));
});
test('src on img', () async {
var page = await loader.getInstance(PageForAttributesTests);
- expect(await page.img.attributes['src'], endsWith('/test.png'));
+ expect(await page.img.seleniumAttributes['src'], endsWith('/test.png'));
});
test('class/className', () async {
var page = await loader.getInstance(PageForAttributesTests);
- expect(await page.table.attributes['class'], 'class1 class2 class3');
- expect(await page.table.attributes['className'], 'class1 class2 class3');
+ expect(await page.table.seleniumAttributes['class'], 'class1 class2 class3');
+ expect(await page.table.seleniumAttributes['className'], 'class1 class2 class3');
});
test('readonly/readOnly', () async {
var page = await loader.getInstance(PageForAttributesTests);
- expect(await page.readOnly.attributes['readonly'], 'true');
- expect(await page.readOnly.attributes['readOnly'], 'true');
- expect(await page.text.attributes['readonly'], isNull);
- expect(await page.text.attributes['readOnly'], isNull);
+ expect(await page.readOnly.seleniumAttributes['readonly'], 'true');
+ expect(await page.readOnly.seleniumAttributes['readOnly'], 'true');
+ expect(await page.text.seleniumAttributes['readonly'], isNull);
+ expect(await page.text.seleniumAttributes['readOnly'], isNull);
});
test('value on text', () async {
var page = await loader.getInstance(PageForAttributesTests);
- expect(await page.text.attributes['value'], '');
+ expect(await page.text.seleniumAttributes['value'], '');
await page.text.type('some text');
- expect(await page.text.attributes['value'], 'some text');
+ expect(await page.text.seleniumAttributes['value'], 'some text');
});
});
}
diff --git a/dart/async/test/src/html_pageloader.dart b/dart/async/test/src/html_pageloader.dart
index d494ab27..7db2086b 100644
--- a/dart/async/test/src/html_pageloader.dart
+++ b/dart/async/test/src/html_pageloader.dart
@@ -29,9 +29,9 @@ void runTests() {
node.onInput.listen((event) {
handlerCalled.complete(true);
});
- expect(await page.text.attributes['value'], '');
+ expect(await page.text.seleniumAttributes['value'], '');
await page.text.type('some text');
- expect(await page.text.attributes['value'], 'some text');
+ expect(await page.text.seleniumAttributes['value'], 'some text');
expect(await handlerCalled.future, isTrue);
});
diff --git a/dart/async/test/src/typing.dart b/dart/async/test/src/typing.dart
index b2b1d952..2859b24d 100644
--- a/dart/async/test/src/typing.dart
+++ b/dart/async/test/src/typing.dart
@@ -23,29 +23,29 @@ void runTests() {
PageForTextAreaTypingText page =
await loader.getInstance(PageForTextAreaTypingText);
await page.textArea.type('some');
- expect(await page.textArea.attributes['value'], 'some');
+ expect(await page.textArea.seleniumAttributes['value'], 'some');
await page.textArea.type(' string');
- expect(await page.textArea.attributes['value'], 'some string');
+ expect(await page.textArea.seleniumAttributes['value'], 'some string');
await page.textArea.clear();
- expect(await page.textArea.attributes['value'], '');
+ expect(await page.textArea.seleniumAttributes['value'], '');
});
test('typing should append', () async {
PageForTypingTests page = await loader.getInstance(PageForTypingTests);
- expect(await page.text.attributes['value'], '');
+ expect(await page.text.seleniumAttributes['value'], '');
await page.text.type('some text');
- expect(await page.text.attributes['value'], 'some text');
+ expect(await page.text.seleniumAttributes['value'], 'some text');
await page.text.type(' and more text');
- expect(await page.text.attributes['value'], 'some text and more text');
+ expect(await page.text.seleniumAttributes['value'], 'some text and more text');
});
test('value after clear', () async {
PageForTypingTests page = await loader.getInstance(PageForTypingTests);
- expect(await page.text.attributes['value'], '');
+ expect(await page.text.seleniumAttributes['value'], '');
await page.text.type('some text');
- expect(await page.text.attributes['value'], 'some text');
+ expect(await page.text.seleniumAttributes['value'], 'some text');
await page.text.clear();
- expect(await page.text.attributes['value'], '');
+ expect(await page.text.seleniumAttributes['value'], '');
});
});
}