I have an app QCalculator with qtwebdriver: https://github.com/cisco-open-source/qtwebdriver/pull/27/files
I am trying to write simple python test, that will test this calculator, here is my script:
#!/usr/bin/env python
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Remote(
desired_capabilities=webdriver.DesiredCapabilities.FIREFOX,
command_executor='http://127.0.0.1:9517'
)
driver.get("qtwidget://Calculator");
btn = driver.find_elements_by_xpath("//Button[@name='5']")[0]
btn.click();
This is interface of Calculator
The script is supposed to click on number "5", but I got this error:
Traceback (most recent call last):
File "./testCalculator.py", line 12, in <module>
btn = driver.find_elements_by_xpath("//Button[@name='5']")[0]
IndexError: list index out of range
Buttons are created like this: (in the link below on github)
for (int i = 1; i < NumDigitButtons; ++i) {
int row = ((9 - i) / 3) + 2;
int column = ((i - 1) % 3) + 1;
mainLayout->addWidget(digitButtons[i], row, column);
}
How to change this code ("//Button[@name='5']")[0] to find the button ?