blob: 24676e896e502720946d2b19788dc8e917f762cc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
/*
* SonarQube
* Copyright (C) 2009-2016 SonarSource SA
* mailto:contact AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package pageobjects.settings;
import com.codeborne.selenide.SelenideElement;
import org.openqa.selenium.By;
import static com.codeborne.selenide.Condition.cssClass;
import static com.codeborne.selenide.Condition.exactValue;
import static com.codeborne.selenide.Condition.exist;
import static com.codeborne.selenide.Condition.visible;
import static com.codeborne.selenide.Selenide.$;
public class SettingsPage {
public SettingsPage() {
$("#settings-page").shouldBe(visible);
}
public SettingsPage assertMenuContains(String categoryName) {
$(".settings-menu").$(By.linkText(categoryName)).shouldBe(visible);
return this;
}
public SettingsPage assertSettingDisplayed(String settingKey) {
$(".settings-definition[data-key='" + settingKey + "']").shouldBe(visible);
return this;
}
public SettingsPage assertSettingNotDisplayed(String settingKey) {
$(".settings-definition[data-key='" + settingKey + "']").shouldNotBe(visible);
return this;
}
public SettingsPage openCategory(String categoryName) {
$(".settings-menu").$(By.linkText(categoryName)).click();
return this;
}
public SettingsPage assertStringSettingValue(String settingKey, String value) {
$("input[name=\"settings[" + settingKey + "]\"]").shouldHave(exactValue(value));
return this;
}
public SettingsPage assertBooleanSettingValue(String settingKey, boolean value) {
SelenideElement toggle = $("button[name=\"settings[" + settingKey + "]\"]");
if (value) {
toggle.shouldHave(cssClass("boolean-toggle-on"));
} else {
toggle.shouldNotHave(cssClass("boolean-toggle-on"));
}
return this;
}
public SettingsPage setStringValue(String settingKey, String value) {
SelenideElement setting = $(".settings-definition[data-key=\"" + settingKey + "\"]");
setting.find("input").val(value);
setting.find(".js-save-changes").click();
setting.find(".js-save-changes").shouldNot(exist);
return this;
}
public PropertySetInput getPropertySetInput(String settingKey) {
SelenideElement setting = $(".settings-definition[data-key=\"" + settingKey + "\"]");
return new PropertySetInput(setting);
}
}
|