以下代码是单击“保存”按钮,但它不起作用&甚至错误也没有显示,我也分享了DOM,请帮助我尝试了classname,xpath,csslocator,Javascript向下滚动,Actions类,但仍然不适合我,请帮助。
WebElement element = driver.findElement(By.xpath(".//*[@type='submit']"));
Actions action = new Actions(driver);
action.moveToElement(element).click().build().perform()
<div class="formRow">
<div class="formRow">
<div class="blueBut1 ml124">
<button class="w150bt fl" type="submit" value="Save Changes">
<a class="fl mt10 ml8" href="/Profile/view?id=&altresid=" rel="last">
</div>
</div>
</form>
</div>
</div>
</div>
答案 0 :(得分:0)
尝试等待元素变为可点击。
WebDriverWait wait = new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.elementToBeClickable(By.xpath(".//*[@type='submit']"))).click();
答案 1 :(得分:0)
尝试使用等待
的xpathWebElement submitButton= driver.findElement(By.xpath("//button[@value='Save Changes']"));
WebDriverWait waitForElement = new WebDriverWait(driver, 30);
waitForElement.until(ExpectedConditions.elementToBeClickable(submitButton))).click();
使用此代码
WebElement submitButton= driver.findElement(By.xpath("//button[@value='Save Changes' and @type='submit']"));
WebDriverWait waitForElement = new WebDriverWait(driver, 30);
waitForElement.until(ExpectedConditions.elementToBeClickable(submitButton))).click();
或
i1 <- seq_len(nrow(DF))
res <- DF[c(rbind(i1[-length(i1)], i1[-1])),]
row.names(res) <- NULL
res
# x y
#1 1 6
#2 2 7
#3 2 7
#4 3 8
#5 3 8
#6 4 9
#7 4 9
#8 5 10
答案 2 :(得分:-1)
尝试以下代码: -
WebElement element = driver.findElement(By.xpath("//button[@type='submit' and @value='Save Changes']"));
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("arguments[0].click();", element);