I'm new to Appium and automation in general.
I'm trying to write a login test. I have six separate LinearLayout
elements and in each of them I need to insert the value "1". I can identify the element (e.g. the element with the id "container_zero"), but I cannot send the value to it neither with the sendKeys()
nor with the setValue()
method.
Also, I tried just to type the required digits using the keyboard below (see the screenshots). But as this is a custom keyboard of the app (not a native Android keyboard), I cannot interact with it. I tried the method driver.pressKey(new KeyEvent())
with AndroidKey.NUMPAD_0
and AndroidKey.DIGIT_0
parameters - didn't work. Keyboard has none elements inside on which I could click (it's just a single element with the android.view.View
class).
I also have an idea to press the required digit on the custom keyboard using the coordinates (X,Y), but I don't think that this is a good way out (maybe when I launch the test on different devices, the coordinates will be different - correct me if I'm wrong).
Please advice what can I do? I thought about using Espresso at this point, but we have the same app on iOS, so for now I think I would try to stick to the Appium for a little while longer due to its cross-platform feature.
but I cannot send the value to it neither with the sendKeys() nor with the setValue() method. - that is correct, you can see attributes of the element and it is not checkable
, clickable
, focusable
etc. So that means that you are not able to sendKeys()
or even click()
on it.
Also, I tried just to type the required digits using the keyboard below (see the screenshots)... - that is the correct behaviour (related to your particular example) too, because there are no different elements of the buttons, only one FrameLayout
for the whole keyboard.
I see two scenarios:
You can ask developer to enable button elements so you will be able to click()
on it
You can calculate coordinates of these buttons in accordance with screen dimension, for example: 1 button = getWindowSize().getWidth() + 50, getWindowSize().getHeight() / 2;
.
This scenario is very unstable because of different devices, but it could work if you find correct dependency between dimension and button positions.
Altogether you either need developer intervention or not so easy calculations for coordinates.