简体   繁体   中英

How to click by robot framework if button is having only class

I need to click the button Calculate on the next webpage

https://www.seb.lv/eng/loan-and-leasing/leasing/leasing-calculator

Button is having next code, as you could see it does not have id or name

<button type="submit" class="btn btn-dark">Calculate</button>

Possibly, I have tried all different constructions according to the Robot framework tutorial, but still without any luck

Also I have tried to emulate the click with Javascript expression (which should be supported by Robot Framework)

Execute Javascript    function getElementByXpath(path) {return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;}; 
     getElementByXpath("//*[@class='btn btn-dark']").click();

Still without any success, although this construction works in the browser console.

Also: had tried this constructions in Firefox and Google Chrome Browsers as from some answers seen from here I was expecting that it could be some certain browser problem.

This button is on a iframe. you should switch to the iframe before trying to click.

driver.switch_to_frame(driver.find_element_by_xpath("//*[@class='calculator-frame']"))
driver.find_element_by_xpath("//*[@class='btn btn-dark']").click()

select frame (SeleniumLibrary) should help:

select frame     css=.calculator-frame
click button     css=.btn-dark

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM