Skip to content

Commit 2bd8ad9

Browse files
committed
implement getAttribute for any proprty that can be converted to string
1 parent 965d236 commit 2bd8ad9

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

src/webdriver/extension_qt/qml_view_executor.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -450,11 +450,12 @@ void QQmlViewCmdExecutor::GetAttribute(const ElementId& element, const std::stri
450450
case QVariant::Double:
451451
val = Value::CreateDoubleValue(propertyValue.toDouble());
452452
break;
453-
case QVariant::String:
454-
val = Value::CreateStringValue(propertyValue.toString().toStdString());
455-
break;
456453
default:
457-
session_->logger().Log(kWarningLogLevel, "cant handle proprty type.");
454+
if (propertyValue.canConvert<QString>()) {
455+
val = Value::CreateStringValue(propertyValue.toString().toStdString());
456+
} else {
457+
session_->logger().Log(kWarningLogLevel, "cant handle proprty type.");
458+
}
458459
}
459460
} else {
460461
session_->logger().Log(kWarningLogLevel, "property not found.");

src/webdriver/extension_qt/quick2_view_executor.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -462,11 +462,12 @@ void Quick2ViewCmdExecutor::GetAttribute(const ElementId& element, const std::st
462462
case QVariant::Double:
463463
val = Value::CreateDoubleValue(propertyValue.toDouble());
464464
break;
465-
case QVariant::String:
466-
val = Value::CreateStringValue(propertyValue.toString().toStdString());
467-
break;
468465
default:
469-
session_->logger().Log(kWarningLogLevel, "cant handle proprty type.");
466+
if (propertyValue.canConvert<QString>()) {
467+
val = Value::CreateStringValue(propertyValue.toString().toStdString());
468+
} else {
469+
session_->logger().Log(kWarningLogLevel, "cant handle proprty type.");
470+
}
470471
}
471472
} else {
472473
session_->logger().Log(kWarningLogLevel, "property not found.");

src/webdriver/extension_qt/widget_view_executor.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -461,11 +461,12 @@ void QWidgetViewCmdExecutor::GetAttribute(const ElementId& element, const std::s
461461
case QVariant::Double:
462462
val = Value::CreateDoubleValue(propertyValue.toDouble());
463463
break;
464-
case QVariant::String:
465-
val = Value::CreateStringValue(propertyValue.toString().toStdString());
466-
break;
467464
default:
468-
session_->logger().Log(kWarningLogLevel, "cant handle proprty type.");
465+
if (propertyValue.canConvert<QString>()) {
466+
val = Value::CreateStringValue(propertyValue.toString().toStdString());
467+
} else {
468+
session_->logger().Log(kWarningLogLevel, "cant handle proprty type.");
469+
}
469470
}
470471
} else {
471472
session_->logger().Log(kWarningLogLevel, "property not found.");

0 commit comments

Comments
 (0)