java - Can we use sendKeys(Keys.RETURN) ,sendKeys(Keys.ENTER) and sendKeys(Keys.SPACE) to click button or select checkbox -


i want know if can use sendkeys(keys.return) , sendkeys(keys.enter) , sendkeys(keys.space) click button or select checkbox.

when using click(); nothing happening (neither clicking on box nor closing browser). when using sendkeys(keys.return); browser closing without selecting box

html:

<section class="payment-buttons">     <div class="section-heading">         <h2>  how 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> 

code:

webdriverwait wait1=new webdriverwait(driver, 10000); wait1.until(expectedconditions.elementtobeclickable(by.xpath("//div[2]/div[2]/section/div[2]/div"))).click(); 

can please tell me how click on button above code?

you can force click element this:

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(); 

hope helps :)


Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -