GUI test case migration is to migrate GUI test cases from a source app to a target app. The key of test case migration is widget match- ing. Recently, researchers have proposed various approaches by formulating widget matching as a matching task. However, since these matching approaches depend on static word embeddings with- out using contextual information to represent widgets and man- ually formulated matching functions, there are main limitations of these matching approaches when handling complex matching relations in apps. To address the limitations, we propose the first learning-based widget matching approach named TEMdroid (TEst Migration) for test case migration. Unlike the existing approaches, TEMdroid uses BERT to capture contextual information and learns a matching model to match widgets. Additionally, to balance the significant imbalance between positive and negative samples in apps, we design a two-stage training strategy where we first train a hard-negative sample miner to mine hard-negative samples, and further train a matching model using positive samples and mined hard-negative samples. Our evaluation on 34 apps shows that TEM- droid is effective in event matching (i.e., widget matching and target event synthesis) and test case migration. For event matching, TEM- droid’s Top1 accuracy is 76%, improving over 17% compared to baselines. For test case migration, TEMdroid’s F1 score is 89%, also 7% improvement compared to the baseline approach.