我们可以使用sendKeys(Keys.RETURN),sendKeys(Keys.ENTER)和sendKeys(Keys.SPACE)来点击按钮或选择复选框

时间:2017-04-06 12:06:06

标签: java html selenium-webdriver

我想知道我们是否可以使用library(dplyr) train %>% summarise_all(function(x) mean(x - mean(x))) # X1 X2 X3 # 0 0 -3.251647e-21 sendKeys(Keys.RETURN)sendKeys(Keys.ENTER)点击按钮或选中复选框。

当我使用sendKeys(Keys.SPACE)时,没有任何事情发生(既不点击框也不关闭浏览器)。 当我使用click();时,浏览器正在关闭而不选择框

HTML:

sendKeys(Keys.RETURN);

代码:

<section class="payment-buttons">
    <div class="section-heading">
        <h2>  How would you like to pay?</h2>
    </div>
    <div class="payment-type-selection clearfix">
        <div class="payment-type creditdebit-btn" data-source="creditdebit" onclick="creditdebitSelect(this,'true');">
            <h5>Credit or Debit Card</h5>
            <i class="icon-cards"></i>
        </div>
        <div class="payment-type paypal-btn" data-source="paypal" onclick="paypalSelect(this,'true');">
            <h5>PayPal</h5>
            <i class="icon-paypal"></i>
        </div>
        <div class="payment-type giftcard-btn" data-source="giftcard" onclick="giftcardSelect(this,'true');">
            <h5>Gift Card</h5>
            <i class="icon-giftcard"></i>
        </div>
    </div>
</section>

有人可以告诉我如何点击上面代码的按钮吗?

1 个答案:

答案 0 :(得分:0)

您可以强制点击此元素:

WebDriverWait wait1=new WebDriverWait(driver, 10000);
Actions actions = new Actions(driver);
actions.moveToElement(wait1.until(driver.findElement(By.xpath("//select[@id='category']/option[@id='cat2']"))).click().build().perform();

希望它可以帮助你:)

相关问题