由于某种原因,新的IntelliJ安装无法登录到GitHub.(凭证是正确的.)
当我尝试"在githu上共享项目"和"从版本控制中检出项目"时,它会发生,选择Git然后尝试登录GitHub.
这是登录提示:
Server: github.com
Login: <my username>
Password: <my password>
Run Code Online (Sandbox Code Playgroud)
并且错误消息:
Invalid authentication data. Can't create token:
scopes - [repo, gist] - not IntelliJ Plugin_1 422
Unprocessable Entity - Validation Failed
[OauthAccess; description]already_exists: null
Run Code Online (Sandbox Code Playgroud)
现在,这是在新安装的Windows 10计算机上,新安装的IntelliJ.所以在系统中的任何地方都没有旧的令牌或类似的东西.这是第一次从IntelliJ访问GitHub的尝试.通过网络登录工作正常.
我有一个表格,其中每一行都有一个下载链接,其中包含(部分)自动生成的 id 元素。这样做的原因是实际的 href 元素始终是“#”,因此 id 将下载分开。
我需要在 td 中找到该 id 元素的名称。也就是说:我知道表格行有一个 id 元素,我知道名称的一部分,我需要得到确切的名称。
我一次访问每一行,所以我一次只需要查看一个 td。无需查看整个表格。
当我知道名称时,我很清楚如何查找元素。但是当我只知道类型时找到元素是另一回事。
...
<tr>
<td class="journalTable-journalPost"
<a class="htext-small" href="#" id="downloadJournalPost-345">Download</a>
</td>
</tr>
<tr>
<td class="journalTable-journalPost"
<a class="htext-small" href="#" id="downloadJournalPost-346">Download</a>
</td>
</tr>
...
Run Code Online (Sandbox Code Playgroud)
我在 webdriver 中找不到任何可以让我按类型查找元素的方法。
部分名称会起作用,因为 id 获得名称“downloadJournalPost-xxx”,其中只有 xxx 更改。但是链接文本是我能找到的唯一值,它可以让我搜索部分匹配。
编辑:更完整的标记。
<td class="journalTable-journalpost">
<span class="hb-tekst--sekundar">In <!----><est-ikon class="ng-star-inserted">
<div aria-hidden="true" class="hb-ikon hb-ikon--pil3-inn ">
<svg focusable="false">
<use xlink:href="#ikon-pil3-inn"></use>
</svg>
</div></est-ikon><!----></span>
<span class="hb-tekst--mellomTittel hb-avstandIngen"> Application and attachments</span>
<a class="hb-tekst--liten" href="#" id="lastNedJournalPost-2892">Download journal post</a>
</td>
Run Code Online (Sandbox Code Playgroud) 抱歉,如果类似问题被问了太多次,但我找到的每个答案似乎都有一个或多个问题。
我有一个字符串形式的日期:例如:“04112005”
这是约会。2005 年 11 月 4 日。
我想获得当前日期和此日期之间的年数和天数差异。
到目前为止,我的代码获取年份并减去它们:
fun getAlderFraFodselsdato(bDate: String): String {
val bYr: Int = getBirthYearFromBirthDate(bDate)
var cYr: Int = Integer.parseInt(SimpleDateFormat("yyyy").format(Date()))
return (cYr-bYr).toString()
}
Run Code Online (Sandbox Code Playgroud)
但是,自然而然,这是非常不准确的,因为不包括月份和日期。
我尝试了几种方法来创建 Date、LocalDate、SimpleDate 等对象,并使用它们来计算差异。但出于某种原因,我没有让他们中的任何一个工作。
我需要创建当前年、月和日的日期(或类似)对象。然后我需要从一个包含月份和年份(“04112005”)的字符串创建相同的对象。然后我需要得到这些之间的差异,以年、月和日为单位。
所有提示表示赞赏。
尝试在页面对象中使用静态方法时,我遇到了NullPointerExceptions的麻烦。如果我使用非静态方法进行操作,则效果很好。
非静态版本:
public class ComplaintPage {
private ExtendedWebDriver driver;
@FindBy(css = "[data-selector=date-received-complaint]")
public WebElement dateComplaintReceoved;
public ComplaintPage() {
driver = Browser.extendedDriver();
PageFactory.initElements(driver, this);
}
public void setComplaintDate() {
dateComplaintReceoved.sendKeys(LocalDate.now().toString());
}
}
Calling code:
ComplaintPage complaintPage = new ComplaintPage;
complaintPage.setComplaintDate();
Run Code Online (Sandbox Code Playgroud)
这很好。日期字段已设置。
静态版
public class ComplaintPage {
private static ExtendedWebDriver driver;
@FindBy(css = "[data-selector=date-received-complaint]")
public static WebElement dateComplaintReceoved;
public ComplaintPage() {
driver = Browser.extendedDriver();
PageFactory.initElements(driver, this);
}
public void static setComplaintDate() {
* dateComplaintReceoved.sendKeys(LocalDate.now().toString());
}
}
Calling code:
ComplaintPage.setComplaintDate();
Run Code Online (Sandbox Code Playgroud)
这不起作用,并在标有“ *”的行(访问WebElement的行)上导致java.lang.NullPointerException。
我有点喜欢在测试中使用像这样的静态方法,因为我并没有真正看到它的问题,它使代码更易于阅读。我以前在C#/ …
java selenium static-methods selenium-chromedriver selenium-webdriver
我在从几个列表(字符串和整数)中获取和返回随机元素时遇到了一些麻烦。问题是每次我运行代码时,这些值确实是随机的。但是对于相同方法的连续调用,值是相似的。
我已将代码缩减为重要部分,因此此处的示例中不包含类定义、导入等。
lonnsinntekter2 += TestsakDataBuilder.createInntekt(
fnr = fnr, arbeid = TestsakDataBuilder.createArbeid()
fun createArbeid(arbeidsgiver: String = randomArbeidsgiver, stillingsprosent: Int =
randomStillingsprosent,
erStillingFast: Boolean = HelperUtils.getRandomBoolean()): Arbeid {
return Arbeid.builder()
.arbeidsgiver(arbeidsgiver)
.stillingsprosent(stillingsprosent)
.erStillingFast(erStillingFast)
.build()
}
}
Run Code Online (Sandbox Code Playgroud)
从上面的代码中调用的randomArbeidsgiver和randomStillingsprosent方法:
val randomArbeidsgiver = listOf("Snusk & Fransen AS", "Humbug Elektro AS", "Hummer & Kanari ANS",
"REMA1000", "Meny", "Gaukern på hjørnet", "Equinor", "Ad Libris").random()
val randomStillingsprosent = listOf(50, 60, 70, 80, 90).random()
Run Code Online (Sandbox Code Playgroud)
我在这里做错了什么?是列表的 .random() 函数在编译时选择值,而不是每次调用时选择值吗?
我最近发现了一个仅根据输入返回值的函数的良好语法:
fun getItem(value: Int): String = when (getPosition(value)) {
0 -> "Zero"
1 -> "One"
2 -> "Two"
else -> "Other"
}
Run Code Online (Sandbox Code Playgroud)
是否还可以使用范围或<>运算符?
我试过做类似的事情:
>0 -> "Positive"
Run Code Online (Sandbox Code Playgroud)
哪个不被接受,并且
0-10 -> "Postively small"
Run Code Online (Sandbox Code Playgroud)
我认为(自然地)被视为“ 0减去10”。