我来编写代码:
driver.get(#####URL#####);
WebDriverWait wait = new WebDriverWait(driver, 120);
//bypass security warning
wait.until(ExpectedConditions.presenceOfElementLocated(By.linkText("Continue to this website (not recommended).")));
WebElement webReport = driver.findElement(By.linkText("Continue to this website (not recommended)."));
builder.moveToElement(webReport).click().perform();
//Login page
wait.until(ExpectedConditions.presenceOfElementLocated(By.name("username")));
WebElement usernameElement = driver.findElement(By.name("username"));
WebElement passwordElement = driver.findElement(By.name("pwd"));
WebElement submitElement = driver.findElement(By.name("B1"));
usernameElement.sendKeys("ABCD.XYZ");
passwordElement.sendKeys("Abcd@1234");
js.executeScript("arguments[0].click();", submitElement);
//code breaks here at the line below, as it doesn't login on submit...and thus can't acccess "menu"
wait.until(ExpectedConditions.presenceOfElementLocated(By.className("menu")));
我期望的唯一结果|运算符是第一个命令的结果。 我看到它的行为就像一个逻辑,还是在第二个命令中添加了元素。
有人可以解释|的工作吗?运算符使用整数作为运算符?
答案 0 :(得分:5)
这只是整数值(1或1 = 1、1或0 = 1、0或1 = 1、0或0 = 0)的二进制表示的每一位之间的逻辑or
val a = 0 | 1
//0 or 1 = 1 (1 - decimal number)
val a = 0 | 1 | 2
//00 or 01 or 10 = 11 (3 - decimal number)
val a = 0 | 1 | 2 | 3
//00 or 01 or 10 or 11 = 11 (3 - decimal number)
val a = 0 | 1 | 2 | 3 | 4
//000 or 001 or 010 or 011 or 100 = 111 (7 - decimal number)
答案 1 :(得分:5)
|
是bitwise OR运算符:
val a = 0 | 1
a: Int = 1
00 0
01 1
-----
01 1
val a = 0 | 1 | 2 | 3
a: Int = 3
00 0
01 1
10 2
11 3
------
11 3
val a = 0 | 1 | 2 | 3 | 4
a: Int = 7
000 0
001 1
010 2
011 3
100 4
-------
111 7