如何使用C#从Web元素获取文本

时间:2016-08-05 14:28:44

标签: c# html selenium

HTML CODE

someFunc <- function(x) {
  if (x < 50) {
    "less"
  } else {
    "greater/equal"
  }
}

set.seed(1234)
input <- sample(100, 10)

## As a for-loop
res <- vector(mode = "character", length = length(input))
for (i in seq_along(input)) {
  res[i] <- someFunc(input[i])
}
res
# [1] "less"          "greater/equal" "greater/equal" "greater/equal"
# [5] "greater/equal" "greater/equal" "less"          "less"         
# [9] "greater/equal" "less"         


## The apply function apprach
sapply(input, someFunc)
# [1] "less"          "greater/equal" "greater/equal" "greater/equal"
# [5] "greater/equal" "greater/equal" "less"          "less"         
# [9] "greater/equal" "less" 

C#CODE

<span id="lbl_OrderNum" class="ff1 fs12 fwb " style="font-size:18px;">      eSYS9778</span>  

如何使用A get text或get属性将文本保存在我的selenium代码中?

1 个答案:

答案 0 :(得分:1)

我注意到使用textContent仅适用于Firefox,如果您使用的是chrome或IE,则需要使用

GetAttribute("innerText")