mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-09 22:44:05 +08:00
fix: run ocr alone without opencv
This commit is contained in:
2
Makefile
2
Makefile
@@ -16,7 +16,7 @@ bump: ## bump hrp version, e.g. make bump version=4.0.0
|
|||||||
.PHONY: build
|
.PHONY: build
|
||||||
build: ## build hrp cli tool
|
build: ## build hrp cli tool
|
||||||
@echo "[info] build hrp cli tool"
|
@echo "[info] build hrp cli tool"
|
||||||
@. scripts/build.sh
|
@. scripts/build.sh $(tags)
|
||||||
|
|
||||||
.PHONY: install-hooks
|
.PHONY: install-hooks
|
||||||
install-hooks: ## install git hooks
|
install-hooks: ## install git hooks
|
||||||
|
|||||||
@@ -64,6 +64,7 @@
|
|||||||
{
|
{
|
||||||
"method": "swipe_to_tap_text",
|
"method": "swipe_to_tap_text",
|
||||||
"params": "轻触进入直播间",
|
"params": "轻触进入直播间",
|
||||||
|
"identifier": "进入直播间",
|
||||||
"max_retry_times": 10
|
"max_retry_times": 10
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -75,7 +76,8 @@
|
|||||||
"actions": [
|
"actions": [
|
||||||
{
|
{
|
||||||
"method": "swipe",
|
"method": "swipe",
|
||||||
"params": "up"
|
"params": "up",
|
||||||
|
"identifier": "第一次上划"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"method": "sleep",
|
"method": "sleep",
|
||||||
@@ -86,7 +88,8 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"method": "swipe",
|
"method": "swipe",
|
||||||
"params": "up"
|
"params": "up",
|
||||||
|
"identifier": "第二次上划"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"method": "sleep",
|
"method": "sleep",
|
||||||
|
|||||||
@@ -33,17 +33,20 @@ teststeps:
|
|||||||
actions:
|
actions:
|
||||||
- method: swipe_to_tap_text
|
- method: swipe_to_tap_text
|
||||||
params: 轻触进入直播间
|
params: 轻触进入直播间
|
||||||
|
identifier: 进入直播间
|
||||||
max_retry_times: 10
|
max_retry_times: 10
|
||||||
- name: 向上滑动,等待 10s
|
- name: 向上滑动,等待 10s
|
||||||
ios:
|
ios:
|
||||||
actions:
|
actions:
|
||||||
- method: swipe
|
- method: swipe
|
||||||
params: up
|
params: up
|
||||||
|
identifier: 第一次上划
|
||||||
- method: sleep
|
- method: sleep
|
||||||
params: 10
|
params: 10
|
||||||
- method: screenshot
|
- method: screenshot
|
||||||
- method: swipe
|
- method: swipe
|
||||||
params: up
|
params: up
|
||||||
|
identifier: 第二次上划
|
||||||
- method: sleep
|
- method: sleep
|
||||||
params: 10
|
params: 10
|
||||||
- method: screenshot
|
- method: screenshot
|
||||||
|
|||||||
@@ -28,6 +28,10 @@ You can get more installation introduction on [hybridgroup/gocv].
|
|||||||
|
|
||||||
OCR API is a paid service, you need to pre-purchase and configure the account key.
|
OCR API is a paid service, you need to pre-purchase and configure the account key.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ make build tags=ocr
|
||||||
|
```
|
||||||
|
|
||||||
## Thanks
|
## Thanks
|
||||||
|
|
||||||
This uixt module is initially forked from [electricbubble/gwda-ext-opencv] and made a lot of changes.
|
This uixt module is initially forked from [electricbubble/gwda-ext-opencv] and made a lot of changes.
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import (
|
|||||||
type TemplateMatchMode int
|
type TemplateMatchMode int
|
||||||
|
|
||||||
type CVArgs struct {
|
type CVArgs struct {
|
||||||
scale float64
|
|
||||||
matchMode TemplateMatchMode
|
matchMode TemplateMatchMode
|
||||||
threshold float64
|
threshold float64
|
||||||
}
|
}
|
||||||
@@ -46,6 +45,7 @@ type DriverExt struct {
|
|||||||
windowSize gwda.Size
|
windowSize gwda.Size
|
||||||
frame *bytes.Buffer
|
frame *bytes.Buffer
|
||||||
doneMjpegStream chan bool
|
doneMjpegStream chan bool
|
||||||
|
scale float64
|
||||||
|
|
||||||
CVArgs
|
CVArgs
|
||||||
}
|
}
|
||||||
@@ -60,6 +60,10 @@ func extend(driver gwda.WebDriver) (dExt *DriverExt, err error) {
|
|||||||
return nil, errors.Wrap(err, "failed to get windows size")
|
return nil, errors.Wrap(err, "failed to get windows size")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if dExt.scale, err = dExt.Scale(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
return dExt, nil
|
return dExt, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,6 +217,12 @@ func (dExt *DriverExt) FindUIRectInUIKit(search string) (x, y, width, height flo
|
|||||||
return dExt.FindImageRectInUIKit(search)
|
return dExt.FindImageRectInUIKit(search)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (dExt *DriverExt) MappingToRectInUIKit(rect image.Rectangle) (x, y, width, height float64) {
|
||||||
|
x, y = float64(rect.Min.X)/dExt.scale, float64(rect.Min.Y)/dExt.scale
|
||||||
|
width, height = float64(rect.Dx())/dExt.scale, float64(rect.Dy())/dExt.scale
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func (dExt *DriverExt) PerformTouchActions(touchActions *gwda.TouchActions) error {
|
func (dExt *DriverExt) PerformTouchActions(touchActions *gwda.TouchActions) error {
|
||||||
return dExt.PerformAppiumTouchActions(touchActions)
|
return dExt.PerformAppiumTouchActions(touchActions)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ package uixt
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"image"
|
"image"
|
||||||
|
"sort"
|
||||||
|
|
||||||
"github.com/electricbubble/gwda"
|
"github.com/electricbubble/gwda"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -4,11 +4,15 @@ package uixt
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"encoding/base64"
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"image"
|
"image"
|
||||||
|
"io/ioutil"
|
||||||
"mime/multipart"
|
"mime/multipart"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var client = &http.Client{
|
var client = &http.Client{
|
||||||
|
|||||||
@@ -22,8 +22,3 @@ func (dExt *DriverExt) FindImageRectInUIKit(imagePath string) (x, y, width, heig
|
|||||||
log.Fatal().Msg("opencv is not supported")
|
log.Fatal().Msg("opencv is not supported")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dExt *DriverExt) MappingToRectInUIKit(rect image.Rectangle) (x, y, width, height float64) {
|
|
||||||
log.Fatal().Msg("opencv is not supported")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -53,10 +53,6 @@ func Extend(driver gwda.WebDriver, options ...CVOption) (dExt *DriverExt, err er
|
|||||||
option(&dExt.CVArgs)
|
option(&dExt.CVArgs)
|
||||||
}
|
}
|
||||||
|
|
||||||
if dExt.scale, err = dExt.Scale(); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if dExt.threshold == 0 {
|
if dExt.threshold == 0 {
|
||||||
dExt.threshold = 0.95 // default threshold
|
dExt.threshold = 0.95 // default threshold
|
||||||
}
|
}
|
||||||
@@ -149,9 +145,3 @@ func getBufFromDisk(name string) (*bytes.Buffer, error) {
|
|||||||
}
|
}
|
||||||
return bytes.NewBuffer(all), nil
|
return bytes.NewBuffer(all), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dExt *DriverExt) MappingToRectInUIKit(rect image.Rectangle) (x, y, width, height float64) {
|
|
||||||
x, y = float64(rect.Min.X)/dExt.scale, float64(rect.Min.Y)/dExt.scale
|
|
||||||
width, height = float64(rect.Dx())/dExt.scale, float64(rect.Dy())/dExt.scale
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -4,8 +4,10 @@
|
|||||||
|
|
||||||
# Usage:
|
# Usage:
|
||||||
# $ make build
|
# $ make build
|
||||||
|
# $ make build tags=ocr
|
||||||
# or
|
# or
|
||||||
# $ bash cli/scripts/build.sh
|
# $ bash scripts/build.sh
|
||||||
|
# $ bash scripts/build.sh ocr
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
set -x
|
set -x
|
||||||
@@ -14,9 +16,15 @@ set -x
|
|||||||
mkdir -p "output"
|
mkdir -p "output"
|
||||||
bin_path="output/hrp"
|
bin_path="output/hrp"
|
||||||
|
|
||||||
# build
|
|
||||||
# optional build tags: opencv ocr
|
# optional build tags: opencv ocr
|
||||||
go build -ldflags '-s -w' -tags ocr -o "$bin_path" hrp/cmd/cli/main.go
|
tags=$1
|
||||||
|
|
||||||
|
# build
|
||||||
|
if [ -z "$tags" ]; then
|
||||||
|
go build -ldflags '-s -w' -o "$bin_path" hrp/cmd/cli/main.go
|
||||||
|
else
|
||||||
|
go build -ldflags '-s -w' -tags "$tags" -o "$bin_path" hrp/cmd/cli/main.go
|
||||||
|
fi
|
||||||
|
|
||||||
# check output and version
|
# check output and version
|
||||||
ls -lh "$bin_path"
|
ls -lh "$bin_path"
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
# release will be triggered on github actions, see .github/workflows/release.yml
|
# release will be triggered on github actions, see .github/workflows/release.yml
|
||||||
|
|
||||||
# Usage:
|
# Usage:
|
||||||
# $ make bump version=v0.5.2
|
# $ make bump version=v4.3.0
|
||||||
# or
|
# or
|
||||||
# $ bash cli/scripts/bump_version.sh v0.5.2
|
# $ bash scripts/bump_version.sh v4.3.0
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user