Skip to content

Commit 0db4bd3

Browse files
author
hekra
committed
GetAttribute for native view returns string
1 parent 5671ed3 commit 0db4bd3

File tree

3 files changed

+12
-49
lines changed

3 files changed

+12
-49
lines changed

src/webdriver/extension_qt/qml_view_executor.cc

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -498,23 +498,10 @@ void QQmlViewCmdExecutor::GetAttribute(const ElementId& element, const std::stri
498498
Value* val = NULL;
499499

500500
if (propertyValue.isValid()) {
501-
// convert QVariant to base::Value
502-
switch (propertyValue.type()) {
503-
case QVariant::Bool:
504-
val = Value::CreateBooleanValue(propertyValue.toBool());
505-
break;
506-
case QVariant::Int:
507-
val = Value::CreateIntegerValue(propertyValue.toInt());
508-
break;
509-
case QVariant::Double:
510-
val = Value::CreateDoubleValue(propertyValue.toDouble());
511-
break;
512-
default:
513-
if (propertyValue.canConvert<QString>()) {
514-
val = Value::CreateStringValue(propertyValue.toString().toStdString());
515-
} else {
516-
session_->logger().Log(kWarningLogLevel, "cant handle proprty type.");
517-
}
501+
if (propertyValue.canConvert<QString>()) {
502+
val = Value::CreateStringValue(propertyValue.toString().toStdString());
503+
} else {
504+
session_->logger().Log(kWarningLogLevel, "cant handle proprty type.");
518505
}
519506
} else {
520507
session_->logger().Log(kWarningLogLevel, "property not found.");

src/webdriver/extension_qt/quick2_view_executor.cc

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -529,22 +529,10 @@ void Quick2ViewCmdExecutor::GetAttribute(const ElementId& element, const std::st
529529

530530
if (propertyValue.isValid()) {
531531
// convert QVariant to base::Value
532-
switch (propertyValue.type()) {
533-
case QVariant::Bool:
534-
val = Value::CreateBooleanValue(propertyValue.toBool());
535-
break;
536-
case QVariant::Int:
537-
val = Value::CreateIntegerValue(propertyValue.toInt());
538-
break;
539-
case QVariant::Double:
540-
val = Value::CreateDoubleValue(propertyValue.toDouble());
541-
break;
542-
default:
543-
if (propertyValue.canConvert<QString>()) {
544-
val = Value::CreateStringValue(propertyValue.toString().toStdString());
545-
} else {
546-
session_->logger().Log(kWarningLogLevel, "cant handle proprty type.");
547-
}
532+
if (propertyValue.canConvert<QString>()) {
533+
val = Value::CreateStringValue(propertyValue.toString().toStdString());
534+
} else {
535+
session_->logger().Log(kWarningLogLevel, "cant handle proprty type.");
548536
}
549537
} else {
550538
session_->logger().Log(kWarningLogLevel, "property not found.");

src/webdriver/extension_qt/widget_view_executor.cc

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -573,22 +573,10 @@ void QWidgetViewCmdExecutor::GetAttribute(const ElementId& element, const std::s
573573

574574
if (propertyValue.isValid()) {
575575
// convert QVariant to base::Value
576-
switch (propertyValue.type()) {
577-
case QVariant::Bool:
578-
val = Value::CreateBooleanValue(propertyValue.toBool());
579-
break;
580-
case QVariant::Int:
581-
val = Value::CreateIntegerValue(propertyValue.toInt());
582-
break;
583-
case QVariant::Double:
584-
val = Value::CreateDoubleValue(propertyValue.toDouble());
585-
break;
586-
default:
587-
if (propertyValue.canConvert<QString>()) {
588-
val = Value::CreateStringValue(propertyValue.toString().toStdString());
589-
} else {
590-
session_->logger().Log(kWarningLogLevel, "cant handle proprty type.");
591-
}
576+
if (propertyValue.canConvert<QString>()) {
577+
val = Value::CreateStringValue(propertyValue.toString().toStdString());
578+
} else {
579+
session_->logger().Log(kWarningLogLevel, "cant handle proprty type.");
592580
}
593581
} else {
594582
session_->logger().Log(kWarningLogLevel, "property not found.");

0 commit comments

Comments
 (0)