Selenium Twitter java(Selenium Twitter java)
我正在尝试使用Selenium Webdriver连接到我的Twitter帐户
WebDriver driver = new FirefoxDriver(); driver.get("https://www.twitter.com/login/"); WebElement formElement = driver.findElement(By.cssSelector("form.signin")); List<WebElement> allFormChildElements = formElement.findElements(By.cssSelector("input")); for(WebElement item : allFormChildElements ) { System.out.println("<"+item.getTagName()+"> "+ item.getAttribute("name") ); switch(item.getAttribute("name")) { case "session[username_or_email]": item.sendKeys(username); break; case "session[password]": item.sendKeys(password); break; } }
但我收到此错误日志:
<input> session[username_or_email] Exception in thread "main" org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with Command duration or timeout: 38 millisecon
DS
我不明白,因为它是打印输入的名称,为什么不可见? 有任何想法吗 ?
谢谢
I'm tryng to get connected to my twitter account using Selenium Webdriver
WebDriver driver = new FirefoxDriver(); driver.get("https://www.twitter.com/login/"); WebElement formElement = driver.findElement(By.cssSelector("form.signin")); List<WebElement> allFormChildElements = formElement.findElements(By.cssSelector("input")); for(WebElement item : allFormChildElements ) { System.out.println("<"+item.getTagName()+"> "+ item.getAttribute("name") ); switch(item.getAttribute("name")) { case "session[username_or_email]": item.sendKeys(username); break; case "session[password]": item.sendKeys(password); break; } }
But i'm getting this error log :
<input> session[username_or_email] Exception in thread "main" org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with Command duration or timeout: 38 millisecon
ds
I don't understand because it is printing the name of the input, why is not visible ? Any ideas ?
Thanks
原文:https://stackoverflow.com/questions/31660151
最满意答案
非转义
^
匹配字符串的开头。 如果您在正则表达式模式中使用它,并且不指定多行标志,则该模式将始终失败,因为字符串的开头不能出现在其中间。你需要逃避
^
和matches()
你不需要锚点。 另外,你可以使用?
(一次或零次出现)或*
(零次或多次出现次数)量词:if(str.matches("-?[0-9]*e\\^-?[0-9]*x"))
查看正则表达式演示
Unescaped
^
matches the beginning of a string. If you use it inside the regex pattern and do not specify the multiline flag, the pattern will always fail since a start of a string cannot appear in the middle of it.You need to escape the
^
and withmatches()
you do not need anchors. Also, you can just use?
(one or zero occurrences) or*
(zero or more occurrences) quantifiers:if(str.matches("-?[0-9]*e\\^-?[0-9]*x"))
See the regex demo
相关问答
更多-
如果您的正则表达式引擎公开了(x + x +)+ y的运行时指数行为,那么它会被破坏,因为DFA或NFA可以在线性时间内识别此模式: echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" | egrep "(x+x+)+y" echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxy" | egrep "(x+x+)+y" 两者都立即回答。 事实上,只有少数情况(如反向引用)真正需要回溯(主要是因为具有反向引用的 ...
-
您的代码应如下所示: function fact(n){ if (n == 1) return 1; return n * fact(n - 1); } function myPow(x, n){ if(n == 1) return n; return x * myPow(x, n - 1); } function expon(x ,n){ if(n == 1){ return 1; } else{ return expon(x, n - 1) ...
-
我认为像这样的场景最好通过在ggplot调用之外使你的function首先处理。 dexp不采用参数,而是使用rate ,与lambda相同。 这意味着你需要基于指数分布属性的rate = 1/18.1 。 另外,我不认为dexp在这里有很多意义,因为它显示了密度,我认为你真的希望概率是pexp 。 你的代码可能看起来像这样: library(ggplot2) test <- function(x) {pexp(x, rate = 1/18.1)} ggplot(df1, aes(x)) + stat_ec ...
-
非转义^匹配字符串的开头。 如果您在正则表达式模式中使用它,并且不指定多行标志,则该模式将始终失败,因为字符串的开头不能出现在其中间。 你需要逃避^和matches()你不需要锚点。 另外,你可以使用? (一次或零次出现)或* (零次或多次出现次数)量词: if(str.matches("-?[0-9]*e\\^-?[0-9]*x")) 查看正则表达式演示 Unescaped ^ matches the beginning of a string. If you use it inside the reg ...
-
X = eps:0.01:1; Y = (X.^3)./(exp(X)-1.0); Z = trapz(X,Y); X = eps:0.01:1; Y = (X.^3)./(exp(X)-1.0); Z = trapz(X,Y);
-
使用Regex处理文本,使用Math来处理数字: Math.Log10(Convert.ToDouble("1.0E-20")) // returns -20 要确保您的字符串输入是有效的double使用TryParse : double d, result = 0.0; if (Double.TryParse("1.0E-20", out d)) { result = Math.Log10(d); } else { // handle error } 此外,如果您想从输入中获得1.0 ...
-
问题在于您使用Combine ,它将所有令牌压缩成一个令牌。 在pyparsing中忽略令牌之间的空格,但令牌中的空格不是。 要解决此问题,请删除Combine ,然后将结果传递给''.join以将其恢复为一个字符串。 The problem is with your use of Combine, which squashes all the tokens together into a single token. Whitespace between tokens is ignored in pypar ...
-
你使用的是哪个版本的python? 找到nth_term的除法在python 2.x和版本3.x中给出不同的结果。 好像你使用的是2.x版。 您使用的除法仅给出整数结果,因此在前两行循环(1 / factorial(0)+ 1 / factorial(1))之后,您只添加零。 因此要么使用版本3.x,要么替换该行 nth_term = float(power)/factorial 或者,正如评论所暗示的那样,通过添加行,使python 2.x像3.x那样进行除法 from __future__ impo ...
-
确保你有最新版本的scikit; 我有不同的系数给你: Slope: [ 0.69314718] Intercept: 4.4408920985e-16 你需要采用整个表达式的exp ,而不仅仅是x项: In [17]: np.exp(0.69314718*1.1 + 4.4408920985e-16) Out[17]: 2.1435469237522917 Make sure you've got the latest version of scikit; I got different coef ...
-
至少有两种方法可以及时线性解决这个问题。 使用中间内存 c1 :: Integer -> Integer c1 n | n <= 4 = n + 10 | otherwise = go n (map c1 [4,3,2,1]) where go 4 (a:_) = a go n [a,b,c,d] = go (n-1) [a + 2*d, a, b, c] 这里我们使用四个中间寄存器,并在循环中移动它们。 我们可以使用元组(a, b, c, d)而不是列表,但是从这里开始映 ...