I want to debug a java program without a main method using selenide tools. I can run the program from command line without any problem but when I try to debug it with VSCode, it outputs
The file 'Weather.java' is not executable. Please select a main class you want to run.
Is there any way to debug my program without using a main method?"
Weather.java
package com.example.app;
import static com.codeborne.selenide.Selenide.*;
// import static com.codeborne.selenide.Condition.*;
// import static com.codeborne.selenide.Selectors.*;
import com.codeborne.selenide.Configuration;
import com.codeborne.selenide.WebDriverRunner;
// import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvFileSource;
class Weather {
@ParameterizedTest
@CsvFileSource(resources = "Weather.csv", numLinesToSkip = 1)
void openWeather(String ward) {
String area = System.getProperty("area");
Configuration.browser = WebDriverRunner.CHROME;
// Configuration.headless = true;
// Googleトップページ
open("https://www.google.co.jp/");
// "天気"を検索
$("input[type=text]").val("天気").pressEnter();
// Youtube検索ページへ飛ぶ
$x("//a[@href='https://weather.yahoo.co.jp/weather/jp/13/4410/13120.html']").click();
$("#searchText").setValue(area);
$("#yjw_button_search").click();
$x("//a[text()= '" + ward + "']").click();
}
}
launch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Debug (Launch) - Current File",
"request": "launch",
"mainClass": "${file}",
"preLaunchTask": "Run Test"
}
]
}
tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "Run Test",
"type": "shell",
"command": "mvn test -Dtest=Weather -Darea=\"東京\"",
"problemMatcher": []
}
]
}
Current versions are as follows:
- selenide:5.5.2
- VSCode:1.41.0
- junit:5.3.2
- Apache Maven:3.6.0