I have an html form outside my android app which part looks like this:
<form action="https://cards-accept.bm.pl/secure_back/play/AW2E8CY8ZG" method="POST"><div class="form-row"><label for="PaRes" data-trans="PaRes"></label><div class="form-field"><textarea id="PaRes" name="PaRes" rows="10" cols="54"><dummy pareq></textarea></div></div><div class="form-row"><label for="MD">MD</label><div class="form-field"><input type="text" name="MD" id="MD" value="29cdce57-e7a1-475f-8243-b141bb2e162f" autocomplete="off"></div></div><div class="tac"><button type="submit" class="btn dark"><span>SUBMIT</span></button></div></form>
I need to click on the button SUBMIT in my test. I have tried to achive that by this code, but failed:
onScreen<MyScreen> {
webView {
withElement(Locator.CLASS_NAME, "btn dark") {
click()
}
}
}
I have an exception as below:
java.lang.RuntimeException: java.lang.RuntimeException: Error in evaluationEvaluation: status: 32 value: {message=Compound class names not permitted} hasMessage: true message: Compound class names not permitted
Is there a way to click on the SUBMIT button in the other way?
CodePudding user response:
using space in class names is not permitted. Space is used to assign multiple classes to a single element.
change the button class name like this:
<button type="submit" class="btn_dark">
and the java code to this:
onScreen<MyScreen> {
webView {
withElement(Locator.CLASS_NAME, "btn_dark") {
click()
}
}
}
CodePudding user response:
To resolve my issue is to use TAG_NAME
, as fortunately, I have only one button
tag in this html present
onScreen<MyScreen> {
webView {
withElement(Locator.TAG_NAME, "button") {
click()
}
}
}