AbstractMethodError for abstract Widget class - since migration to byte-buddy
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 50/100
- Tipo de issue
- Bug
- Clareza
- Razoavelmente clara
- Status de atividade
- Estagnada
- Domínio
- mobile-dev, testing-qa
Direção de pesquisa
Comece com o exemplo de Widget abstrato em Page-objects.md e rastreie como OverrideWidget, WidgetInterceptor e field.getType() selecionam a classe do widget. Reproduza os casos de Android e iOS da issue e, em seguida, verifique se as chamadas às implementações da plataforma não geram mais AbstractMethodError ao usar Byte Buddy.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Is there an existing issue for this?
- I have searched the existing issues
Appium Version
2.0.1
Appium Host Type
Command Line
Are you using Appium components not maintained by the Appium team?
No response
Is this issue reproducible using the latest components?
- I confirm the issue is still reproducible with the latest component versions
Current Behavior
Currently my repo(Android & iOS combined) is using java-client version: 8.3.0
I did not update my version since I got issues with the new byte buddy library. I tried to update to the latest java client version(10.0.0) and still, I get the same issue.
The issue:
I am working according to this docs: PO - abstract Widget class.
When I run my tests using a java client with byte buddy I get AbstractMethodError.
Expected Behavior
To work as it did with cglib.
Appium Log
No response
Environment Details
- Debug details (
appium --show-debug-info): - Last component version(s) which did not exhibit the problem: appium 2.0.1, java-client 10.0.0
- Platform and version of device under test: android
- Real device or emulator/simulator: emulator
Minimal Reproducible Example
Reproduction:
Consider the following setup in your PO:
public class MyPO {
@OverrideWidget(androidUIAutomator = CustomWidget.AndroidCustomWidget.class, iOSXCUITAutomation = CustomWidget.IOSCustomWidget.class)
private CustomWidget myCustomWidget;
}
Your Widget class:
public abstract class CustomWidget extends Widget {
public abstract void abstractTest();
public static class AndroidCustomWidget extends CustomWidget {
@Override
public void abstractTest() {
//android implementation
}
}
public static class IOSCustomWidget extends CustomWidget {
@Override
public void abstractTest() {
//iOS implementation
}
}
}
Then in the test class just call:
myPO.getCustomWidget().abstractTest();
You'll get AbstractMethodError since byte buddy tries to call the original abstract method signature
Further Information
I also managed to find the issue and fix it locally. I will detail my steps here.
First, acording to this Callable implements no-abstract methods by default ByteBuddy's proxies(which are essentially just subclasses) subclass the Widget class and passing calls to the Interceptor(in our case Appium's WidgetInterceptor) for non-abstract methods. The issue is that it subclasses the original CustomWidget and thus it cannot call myWidget.abstractTest() and throwing AbstractMethodError. Instead, it needs to subclass AndroidCustomWidget or IOSCustomWidget according to the platform we are currently using. Since the abstractTest method is non-abstract in AndroidCustomWidget and IOSCustomWidget, byte buddy will override and intercept those methods as well - resulting in the desired behavior.
Fix example:
I was just testing and found out that the java client passes widgetType = (Class<? extends Widget>) field.getType(); which in our case is the abstract class CustomWidget, I added a check for android OverrideWidget and it worked perfectly(since the widgetType is now of type AndroidCustomWidget). In cglib it used to work but I guess byte buddy implements things differently so the the code needs to take into consideration the current platform and the Widget class that overrides it.
- Linguagem predominante
- Java
- Estrelas
- 1.3k
- Forks
- 755
- Merge médio
- 5d 14h
- PRs com merge (30d)
- 8
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Sem guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de appium/java-client
-
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 25/100
appium/java-client#2426 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 30/100
appium/java-client#2368 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 30/100
appium/java-client#2341 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 15/100
appium/java-client#2323 ·
Mantenedores costumam responder em até 1 dia
-
java-client 启动报错Aberta
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 35/100
appium/java-client#2288 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
Todas as issues de appium/java-client
Issues semelhantes
-
P2 testing
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 90/100
Mantenedores costumam responder em até 1 dia
-
area/core kind/bug status/triage team/core-shared
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
checkstyle/checkstyle#21755 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
spring-projects/spring-integration#11495 ·
Mantenedores costumam responder em até 2 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
Mantenedores costumam responder em até 1 dia