Skip to content
This repository was archived by the owner on Oct 25, 2023. It is now read-only.

add getting result image by find by image#327

Merged
KazuCocoa merged 3 commits intoappium:masterfrom
KazuCocoa:km/add-getting-result-image
May 29, 2019
Merged

add getting result image by find by image#327
KazuCocoa merged 3 commits intoappium:masterfrom
KazuCocoa:km/add-getting-result-image

Conversation

@KazuCocoa
Copy link
Copy Markdown
Member

closes appium/appium#12506

What this will do

  • Store the result of find by image in ImageElement
    • It is available only when getMatchedImageResult is true via settings API
  • Users can get the data via getAttribute API as visual
    • e.g. Ruby: element.visual, Python: element.getAttribute('visual') etc

The visual

example in Ruby

> @driver.update_settings({ fixImageTemplateScale: true, getMatchedImageResult: false })=> nil
> @core.wait { @@driver.find_element_by_image AppiumLibCoreTest.path_of('test/functional/data/test_ios_button.png') }
=> #<Selenium::WebDriver::Element:0x7144c4bf699ffe78 id="appium-image-element-758743a6-7c14-4a90-932c-be7d247faef8">
> image_element.visual
=> nil
> @driver.update_settings({ fixImageTemplateScale: true, getMatchedImageResult: true })=> nil
> image_element = @@core.wait { @@driver.find_element_by_image AppiumLibCoreTest.path_of('test/functional/data/test_ios_button.png') }
=> #<Selenium::WebDriver::Element:0x..f814fd569a6a19222 id="appium-image-element-efb92580-e72a-4d96-9a61-4ea45137cd27">
> v = image_element.visual
=> "iVBORw0KGgoAAAANSUhEUgAAAXcAAAKbCAIAAACBzF3NAAAgAElEQVR4AezBC5SP1f4A/O/e+7n9rnM1YxgOE5FQ+QspoRDFTG6FiKKYRhqGSaHkLk0qJKEc5VqoSTdJF+pBShlyN+aMGcx9frfnuvd+1/tb76zVWvWuznSylnM8nw969NFHweFwOK4YtG/fPnA4HI4rBu3fvx8cDofjikH79u0Dh8PhuGKQqqrwR2zbBgBCiCAIUAchZNs2/FW6rjPGAMDv99u2DX+VbdsIIYyxIAiGYSCEOOeMMYwxIQRjzDnXdd3tdiOEDMMQBAGuJZRSqCPLMgBwziml8BuEEF3XEUKKoti2DX9EFMVIJMIYkySJUooQwhgjhACAc84Y41HwG7IsM8Y0TXO5XPAbnHPGGOccIQR1LMuSZRkhZBiGLMvwG5xzAMAYc87BUX+UUhSFMdY0Df4qWZYjkUhMTE..."
> image_element.unsupported_attribute
Selenium::WebDriver::Error::UnknownMethodError: Method has not yet been implemented
from NotYetImplementedError: Method has not yet been implemented

Will add this debug feature in http://appium.io/docs/en/advanced-concepts/image-elements/

@KazuCocoa KazuCocoa requested a review from jlipps May 29, 2019 02:35
Copy link
Copy Markdown
Member

@jlipps jlipps left a comment

Choose a reason for hiding this comment

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

great idea!

// e.g. ["content-desc","appium-image-element-xxxxx","xxxxx"], ["visual","appium-image-element-xxxxx","xxxxx"]
if (args[0] === 'visual') {
return imgEl.matchedImage;
} else {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

pretty sure this else block is not necessary (without a break or return, the default case will also be executed)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, but the lint claimed about this point.
I compared adding an ignoring the lint message vs adding this else block.

Which is safer in JS world? (I thought following the lint was safer for now.)

@atimofeev86
Copy link
Copy Markdown

what about c#?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Return matched image by find element/s by image like visualize arg in image comparison

3 participants