appium问题an X display is required for keycode conversions, consider using Xvfb解决sendKey卡住

问题描述:
当使用appium 的java-client依赖去调用sendKey方法向控件发送文本时候,appium服务器报错如下:
unknown error: an X display is required for keycode conversions, consider using Xvfb

在window的开发环境中,调整chromeDriver的版本,手机使用系统自带的输入键盘,查找到对应控件后,能正常sendKey。
但在linux环境下却不行,排除了chromeDriver的版本和appium版本问题后,结合网上资料,网上并没有具体的解决办法。
再git上找到一个类似的解决描述:

Ensure seleniumAddress: 'http://localhost:4444/wd/hub' matches your selenium server and avoid setting chromeOnly since that will effectively avoid using the headless selenium server.

Also, Xvfb needs to run before webdriver-manager and you're missing xvfb-run given you seem to need it to do the X authority dance for you:

#!/bin/sh

export DISPLAY=:1

Xvfb $DISPLAY -ac -screen 0 1280x1024x8 &
sleep 1

xvfb-run webdriver-manager start &

最后具体了解linux 下的xvfb的原理,测试尝试解决成功解决sendKey报错问题。

首先linux下需要安装Xvfb ,对应的centos系统安装yum -y install Xvfb

安装成功后,启动Xvfb:

Xvfb :1 -ac -screen 0 1280x1024x8 &

然后通过xvfb启动appium服务

xvfb-run appium -p4725 &
或者到appium源码目录下node .执行
xvfb-run node . -p4725 &

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值