我正在尝试使用 detox 测试我的 react-native 应用程序,等待文本输入可见并在其中键入文本。我的 spec JS 文件 如下所示:
describe('FiestTest', () => {
beforeEach(async () => {
await device.reloadReactNative()
})
it('Login to a test account', async () => {
// LoginPage: entering phone number moving to next page
await expect(element(by.id('LoginPage-phoneInput'))).toBeVisible()
await element(by.id('LoginPage-phoneInput')).typeText('<someNumber>')
})
})
我得到的错误是:
FiestTest
1) Enter phone number and tap on button
0 passing (15s)
1 failing
1) FiestTest Enter phone number and tap on button:
Error: An action failed. Please refer to the error trace below.
Exception with Action: {
"Action Name" : "Type '6219'",
"Element Matcher" : "(((respondsToSelector(accessibilityIdentifier) && accessibilityID('ValidatePage-txtField')) && !(kindOfClass('RCTScrollView'))) || (kindOfClass('UIScrollView') && ((kindOfClass('UIView') || respondsToSelector(accessibilityContainer)) && ancestorThatMatches(((respondsToSelector(accessibilityIdentifier) && accessibilityID('ValidatePage-txtField')) && kindOfClass('RCTScrollView'))))))"
}
Error Trace: [
{
"Description" : "Failed to type string '6219', because keyboard was not shown on screen.",
"Error Domain" : "com.google.earlgrey.ElementInteractionErrorDomain",
"Error Code" : "2",
"File Name" : "GREYKeyboard.m",
"Function Name" : "+[GREYKeyboard typeString:inFirstResponder:error:]",
"Line" : "168"
}
]
我正在使用以下工具:
$ npm outdate
Package Current Wanted Latest Location
apollo-client 1.4.0 1.9.0 1.9.0 <appName>
babel-jest 19.0.0 19.0.0 20.0.3 <appName>
babel-plugin-module-resolver 2.7.0 2.7.1 2.7.1 <appName>
eslint 3.19.0 3.19.0 4.4.1 <appName>
eslint-plugin-import 2.2.0 2.7.0 2.7.0 <appName>
eslint-plugin-node 4.2.2 4.2.3 5.1.1 <appName>
eslint-plugin-react 6.10.3 6.10.3 7.1.0 <appName>
eslint-plugin-react-native 2.3.2 2.3.2 3.0.1 <appName>
graphql-tag 2.2.1 2.4.2 2.4.2 <appName>
jest 19.0.2 19.0.2 20.0.4 <appName>
moment-jalaali 0.6.1 0.6.1 0.7.0 <appName>
native-base 2.1.4 2.3.1 2.3.1 <appName>
react 16.0.0-alpha.6 16.0.0-alpha.6 15.6.1 <appName>
react-apollo 1.4.2 1.4.11 1.4.11 <appName>
react-native 0.44.0 0.44.0 0.47.1 <appName>
react-native-adjust 4.11.3 4.11.4 4.11.4 <appName>
react-native-fcm 6.2.3 6.2.3 8.0.0 <appName>
react-native-popup-menu 0.7.3 0.7.5 0.8.0 <appName>
react-native-router-flux 3.39.1 3.41.0 4.0.0-beta.16 <appName>
react-native-sentry 0.12.9 0.12.12 0.15.1 <appName>
react-native-smart-splash-screen 2.3.3 2.3.4 2.3.4 <appName>
react-test-renderer 15.4.2 15.4.2 15.6.1 <appName>
redux 3.6.0 3.7.2 3.7.2 <appName>
redux-persist 4.6.0 4.8.3 4.8.3 <appName>
这是我的播客文件:
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
target '<appName>' do
# Uncomment this line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!
# Pods for <appName>
pod 'Firebase'
pod 'Firebase/Core'
pod 'Firebase/Analytics'
pod 'Firebase/Messaging'
pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
pod 'React', :path => '../node_modules/react-native', :subspecs => [
'RCTText',
'RCTImage',
'RCTNetwork',
'RCTWebSocket',
]
#target '<appName>-tvOSTests' do
# inherit! :search_paths
# Pods for testing
#end
#target '<appName>Tests' do
# inherit! :search_paths
# Pods for testing
#end
end
#target '<appName>-tvOS' do
# Uncomment this line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!
# Pods for <appName>-tvOS
# target '<appName>-tvOSTests' do
# inherit! :search_paths
# Pods for testing
# end
#end
现在我只是使用像波纹管这样的 sleep 命令,以便给我时间手动插入字符串。然而,这不应该是一个永久的解决方案......
function sleep (ms) {
return new Promise(resolve => setTimeout(resolve, ms))
}
await sleep(milliseconds)
// what needs to happen after I manually enter the code
我还在 GitHub 上的 Detox 问题中发表了评论,但想知道是否有人有同样的经历并在这里找到了解决方案。
提前感谢您的协助!
最佳答案
你应该跑
await element(by.id('LoginPage-phoneInput')).tap();
之前
await element(by.id('LoginPage-phoneInput')).typeText('<someNumber>')
关于javascript - 排毒 _ 无法键入字符串,因为键盘未显示在屏幕上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45561935/
总的来说,我对ruby还比较陌生,我正在为我正在创建的对象编写一些rspec测试用例。许多测试用例都非常基础,我只是想确保正确填充和返回值。我想知道是否有办法使用循环结构来执行此操作。不必为我要测试的每个方法都设置一个assertEquals。例如:describeitem,"TestingtheItem"doit"willhaveanullvaluetostart"doitem=Item.new#HereIcoulddotheitem.name.shouldbe_nil#thenIcoulddoitem.category.shouldbe_nilendend但我想要一些方法来使用
我有一个字符串input="maybe(thisis|thatwas)some((nice|ugly)(day|night)|(strange(weather|time)))"Ruby中解析该字符串的最佳方法是什么?我的意思是脚本应该能够像这样构建句子:maybethisissomeuglynightmaybethatwassomenicenightmaybethiswassomestrangetime等等,你明白了......我应该一个字符一个字符地读取字符串并构建一个带有堆栈的状态机来存储括号值以供以后计算,还是有更好的方法?也许为此目的准备了一个开箱即用的库?
我的目标是转换表单输入,例如“100兆字节”或“1GB”,并将其转换为我可以存储在数据库中的文件大小(以千字节为单位)。目前,我有这个:defquota_convert@regex=/([0-9]+)(.*)s/@sizes=%w{kilobytemegabytegigabyte}m=self.quota.match(@regex)if@sizes.include?m[2]eval("self.quota=#{m[1]}.#{m[2]}")endend这有效,但前提是输入是倍数(“gigabytes”,而不是“gigabyte”)并且由于使用了eval看起来疯狂不安全。所以,功能正常,
在我的Rails(2.3,Ruby1.8.7)应用程序中,我需要将字符串截断到一定长度。该字符串是unicode,在控制台中运行测试时,例如'א'.length,我意识到返回了双倍长度。我想要一个与编码无关的长度,以便对unicode字符串或latin1编码字符串进行相同的截断。我已经了解了Ruby的大部分unicode资料,但仍然有些一头雾水。应该如何解决这个问题? 最佳答案 Rails有一个返回多字节字符的mb_chars方法。试试unicode_string.mb_chars.slice(0,50)
我在从html页面生成PDF时遇到问题。我正在使用PDFkit。在安装它的过程中,我注意到我需要wkhtmltopdf。所以我也安装了它。我做了PDFkit的文档所说的一切......现在我在尝试加载PDF时遇到了这个错误。这里是错误:commandfailed:"/usr/local/bin/wkhtmltopdf""--margin-right""0.75in""--page-size""Letter""--margin-top""0.75in""--margin-bottom""0.75in""--encoding""UTF-8""--margin-left""0.75in""-
对于具有离线功能的智能手机应用程序,我正在为Xml文件创建单向文本同步。我希望我的服务器将增量/差异(例如GNU差异补丁)发送到目标设备。这是计划:Time=0Server:hasversion_1ofXmlfile(~800kiB)Client:hasversion_1ofXmlfile(~800kiB)Time=1Server:hasversion_1andversion_2ofXmlfile(each~800kiB)computesdeltaoftheseversions(=patch)(~10kiB)sendspatchtoClient(~10kiBtransferred)Cl
我得到了一个包含嵌套链接的表单。编辑时链接字段为空的问题。这是我的表格:Editingkategori{:action=>'update',:id=>@konkurrancer.id})do|f|%>'Trackingurl',:style=>'width:500;'%>'Editkonkurrence'%>|我的konkurrencer模型:has_one:link我的链接模型:classLink我的konkurrancer编辑操作:defedit@konkurrancer=Konkurrancer.find(params[:id])@konkurrancer.link_attrib
大约一年前,我决定确保每个包含非唯一文本的Flash通知都将从模块中的方法中获取文本。我这样做的最初原因是为了避免一遍又一遍地输入相同的字符串。如果我想更改措辞,我可以在一个地方轻松完成,而且一遍又一遍地重复同一件事而出现拼写错误的可能性也会降低。我最终得到的是这样的:moduleMessagesdefformat_error_messages(errors)errors.map{|attribute,message|"Error:#{attribute.to_s.titleize}#{message}."}enddeferror_message_could_not_find(obje
我试图获取一个长度在1到10之间的字符串,并输出将字符串分解为大小为1、2或3的连续子字符串的所有可能方式。例如:输入:123456将整数分割成单个字符,然后继续查找组合。该代码将返回以下所有数组。[1,2,3,4,5,6][12,3,4,5,6][1,23,4,5,6][1,2,34,5,6][1,2,3,45,6][1,2,3,4,56][12,34,5,6][12,3,45,6][12,3,4,56][1,23,45,6][1,2,34,56][1,23,4,56][12,34,56][123,4,5,6][1,234,5,6][1,2,345,6][1,2,3,456][123
我正在使用的第三方API的文档状态:"[O]urAPIonlyacceptspaddedBase64encodedstrings."什么是“填充的Base64编码字符串”以及如何在Ruby中生成它们。下面的代码是我第一次尝试创建转换为Base64的JSON格式数据。xa=Base64.encode64(a.to_json) 最佳答案 他们说的padding其实就是Base64本身的一部分。它是末尾的“=”和“==”。Base64将3个字节的数据包编码为4个编码字符。所以如果你的输入数据有长度n和n%3=1=>"=="末尾用于填充n%