我想从文本框中获取值。
使用如下方法:
element(by.xpath('//*[id="answer_1_total"]')).getText().then(function(text){
var value=text.toString();
console.log(value);
});
元素包含数值。我申请按钮的代码行相同,但工作正常。
当我执行此操作时,没有任何内容显示出来,所以我的理解是这些行没有被执行。
注意:我尝试getText()
而不是getAttribute('value')
,而不是ng-repeat
,而不是成功。
请帮助我,因为我在过去的2天内坚持这一点。
答案 0 :(得分:0)
仅打印 getText()
值
actionResults_:
{ closure_uid_189613320: 1023,
parent_: [Object],
callbacks_: null,
state_: 'pending',
handled_: false,
pendingNotifications_: false,
value_: undefined },
locator_: { using: 'id', value: 'currencysumDisplay_1_answer' },
click: [Function],
sendKeys: [Function],
getText: [Function],
isDisplayed: [Function],
getId: [Function],
getRawId: [Function] },
点击:[功能],enter code here
sendKeys:[功能],
getText:[功能],
这是getText()
值,如果我尝试将其更改为toString()
,那么它会在控制台中显示[object Object]
答案 1 :(得分:0)
根据您的回答(实际上不是答案),您试图在控制台上打印出 getText()
实例字符串表示。而是打印从element(by.xpath('//*[id="answer_1_total"]')).getText().then(function(text) {
console.log(text);
});
promise:
element(by.xpath('//*[id="answer_1_total"]')).getText().then(console.log);
或者,简短版本:
.global main
.func main
main:
MOV R3, #0 @ initialze index variable
BL writeloop @ call write function
BL readloop @call read function (prints a)
writeloop:
CMP R3, #10 @ check to see if we are done iterating
BEQ writedone @ exit loop if done
LDR R1, =a @ get address of a
LSL R2, R3, #2 @ multiply index*4 to get array offset
ADD R2, R1, R2 @ R2 now has the element address
BL _scanf
MOV R4,R0
STR R4, [R2] @ write input to a[i]
ADD R3, R3, #1 @ increment index
B writeloop @ branch to next loop iteration
writedone:
MOV R3, #0 @ initialze index variable
readloop:
CMP R3, #10 @ check to see if we are done iterating
BEQ readdone @ exit loop if done
LDR R1, =a @ get address of a
LSL R2, R3, #2 @ multiply index*4 to get array offset
ADD R2, R1, R2 @ R2 now has the element address
LDR R1, [R2] @ read the array at address
PUSH {R3} @ backup register before printf
PUSH {R1} @ backup register before printf
PUSH {R2} @ backup register before printf
MOV R2, R1 @ move array value to R2 for printf
MOV R1, R3 @ move array index to R1 for printf
BL _printf @ branch to print procedure with return
POP {R2} @ restore register
POP {R1} @ restore register
POP {R3} @ restore register
ADD R3, R3, #1 @ increment index
B readloop @ branch to next loop iteration
readdone:
MOV R3,#0 @reset counter (i)
_exit:
MOV R7, #4 @ write syscall, 4
MOV R0, #1 @ output stream to monitor, 1
MOV R2, #21 @ print string length
LDR R1, =exit_str @ string at label exit_str:
SWI 0 @ execute syscall
MOV R7, #1 @ terminate syscall, 1
SWI 0 @ execute syscall
@ ---- Moved below _exit, added R2 and R3 to PUSH and POP
_scanf:
PUSH {LR} @ store the return address
PUSH {R1, R2, R3} @ backup regsiter value
LDR R0, =format_str @ R0 contains address of format string
SUB SP, SP, #4 @ make room on stack
MOV R1, SP @ move SP to R1 to store entry on stack
BL scanf @ call scanf
LDR R0, [SP] @ load value at SP into R0
ADD SP, SP, #4 @ remove value from stack
POP {R1, R2, R3} @ restore register value
POP {PC} @ restore the stack pointer and return
_printf:
PUSH {LR} @ store the return address
LDR R0, =printf_str @ R0 contains formatted string address
BL printf @ call printf
POP {PC} @ restore the stack pointer and return
.data
format_str: .asciz "%d"
.balign 4
a: .skip 40
printf_str: .asciz "a[%d] = %d\n"
exit_str: .ascii "Terminating program.\n"