Java Code Examples for com.codeborne.selenide.SelenideElement#click()
The following examples show how to use
com.codeborne.selenide.SelenideElement#click() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DebugUtilsTest.java From neodymium-library with MIT License | 6 votes |
@Test public void testIFrames() throws Exception { Neodymium.configuration().setProperty("neodymium.debugUtils.highlight", "true"); Neodymium.configuration().setProperty("neodymium.debugUtils.highlight.duration", "750"); Selenide.open("https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_select"); Neodymium.getDriver().switchTo().frame("iframeResult"); SelenideElement body = $("body"); body.click(); assertJsSuccessfullyInjected(); final List<WebElement> list = $("body").findElements(By.cssSelector("select")); Neodymium.configuration().setProperty("neodymium.debugUtils.highlight", "false"); DebugUtils.highlightElements(list, Neodymium.getDriver()); $(".neodymium-highlight-box").shouldBe(visible); DebugUtils.resetAllHighlight(); $(".neodymium-highlight-box").shouldNot(exist); }
Example 2
Source File: SideMenuImpl.java From masquerade with Apache License 2.0 | 6 votes |
@Override public void openItem(String... path) { for (String s : path) { String itemXpath = String.format( "//div[contains(@class, 'c-sidemenu-item') and @cuba-id=%s]", Quotes.escape(s)); SelenideElement menuItemElement = $(byXpath(itemXpath)) .shouldBe(visible) .shouldBe(enabled); Wait().until(elementToBeClickable(menuItemElement)); if (!menuItemElement.has(cssClass(SIDE_MENU_ITEM_HEADER_OPEN))) { menuItemElement.click(); } } }
Example 3
Source File: AppMenuImpl.java From masquerade with Apache License 2.0 | 6 votes |
@Override public void openItem(String... path) { for (int i = 0; i < path.length; i++) { String s = path[i]; String itemXpath = "//span[contains(@class, 'v-menubar-menuitem') " + "and @cuba-id=" + Quotes.escape(s) + "]"; SelenideElement menuItemElement; if (i == 0) { menuItemElement = $(byXpath(itemXpath)); } else { // Firefox requires click on caption in submenus menuItemElement = $(byChain(byXpath(itemXpath), byClassName("v-menubar-menuitem-caption"))); } menuItemElement .shouldBe(visible) .shouldBe(enabled); Wait().until(elementToBeClickable(menuItemElement)); menuItemElement.click(); } }
Example 4
Source File: TableImpl.java From masquerade with Apache License 2.0 | 5 votes |
@Override public Table sort(String columnId, SortDirection direction) { if (columnId.startsWith("column_")) { columnId = columnId.substring("column_".length()); } SelenideElement columnHeaderCell = $(byChain(by, byClassName("v-table-header"), byCubaId("column_" + columnId))) .shouldBe(visible) .shouldHave(cssClass("v-table-header-sortable")); SortDirection currentDirection = getSortDirection(columnHeaderCell); // lets calculate exact click count, because sort can be slow for (int i = 0; i < getSortClickCount(currentDirection, direction); i++) { columnHeaderCell.click(); } // final check String directionSuffix = toSortSuffix(direction); if (!directionSuffix.isEmpty()) { columnHeaderCell.shouldHave(cssClass("v-table-header-cell-" + directionSuffix)); } else { columnHeaderCell .shouldNotHave(cssClass("v-table-header-cell-asc")) .shouldNotHave(cssClass("v-table-header-cell-desc")); } return this; }
Example 5
Source File: GoogleTestWithDockerNoVideo.java From testcontainers with MIT License | 5 votes |
@Test public void search() { open("https://google.com/ncr"); $(By.name("q")).val("Selenide").pressEnter(); $$("#res .g").shouldHave(sizeGreaterThan(3)); for (int i = 0; i < 3; i++) { SelenideElement link = $("#res .g", i).find("a"); System.out.println(link.attr("href")); link.click(); back(); } sleep(1000); }
Example 6
Source File: GoogleTestWithDocker.java From testcontainers with MIT License | 5 votes |
@Test public void search() { open("https://google.com/ncr"); $(By.name("q")).val("Selenide").pressEnter(); $$("#res .g").shouldHave(sizeGreaterThan(3)); for (int i = 0; i < 3; i++) { SelenideElement link = $("#res .g", i).find("a"); System.out.println(link.attr("href")); link.click(); back(); } sleep(1000); }
Example 7
Source File: GoogleTestWithDockerTestNG.java From testcontainers with MIT License | 5 votes |
@Test public void search() { open("https://google.com/ncr"); $(By.name("q")).val("Selenide").pressEnter(); $$("#res .g").shouldHave(sizeGreaterThan(3)); for (int i = 0; i < 3; i++) { SelenideElement link = $("#res .g", i).find("a"); System.out.println(link.attr("href")); link.click(); back(); } sleep(1000); }
Example 8
Source File: SelenideGlobalConfigJupiterTest.java From selenium-jupiter with Apache License 2.0 | 5 votes |
@Test public void testSelenideConfig(SelenideDriver driver) { driver.open("https://bonigarcia.github.io/selenium-jupiter/"); SelenideElement about = driver.$(linkText("About")); about.shouldBe(visible); about.click(); }
Example 9
Source File: SelenideDefaultJupiterTest.java From selenium-jupiter with Apache License 2.0 | 5 votes |
@Test public void testSelenide(SelenideDriver driver) { driver.open("https://bonigarcia.github.io/selenium-jupiter/"); SelenideElement about = driver.$(linkText("About")); about.shouldBe(visible); about.click(); }
Example 10
Source File: SelenideDockerJupiterTest.java From selenium-jupiter with Apache License 2.0 | 5 votes |
@Test public void testDockerSelenideChrome( @DockerBrowser(type = CHROME) SelenideDriver driver) { driver.open("https://bonigarcia.github.io/selenium-jupiter/"); SelenideElement about = driver.$(linkText("About")); about.shouldBe(visible); about.click(); }
Example 11
Source File: TableImpl.java From masquerade with Apache License 2.0 | 5 votes |
@Override public SelenideElement selectRow(By rowBy) { this.shouldBe(VISIBLE) .shouldBe(ENABLED); SelenideElement row = getRow(rowBy) .shouldBe(visible); row.click(); return row; }
Example 12
Source File: DataGridImpl.java From masquerade with Apache License 2.0 | 5 votes |
@Override public DataGrid sort(String columnId, SortDirection direction) { if (columnId.startsWith("column_")) { columnId = columnId.substring("column_".length()); } SelenideElement columnHeaderCell = $(byChain(by, byClassName("v-grid-header"), byCubaId("column_" + columnId))) .shouldBe(visible) .shouldHave(cssClass("sortable")); DataGrid.SortDirection currentDirection = getSortDirection(columnHeaderCell); // lets calculate exact click count, because sort can be slow for (int i = 0; i < getSortClickCount(currentDirection, direction); i++) { columnHeaderCell.click(); } // final check String directionSuffix = toSortSuffix(direction); if (!directionSuffix.isEmpty()) { columnHeaderCell.shouldHave(cssClass("sort-" + directionSuffix)); } else { columnHeaderCell .shouldNotHave(cssClass("sort-asc")) .shouldNotHave(cssClass("sort-desc")); } return this; }
Example 13
Source File: DataGridImpl.java From masquerade with Apache License 2.0 | 5 votes |
@Override public SelenideElement selectRow(By rowBy) { this.shouldBe(VISIBLE) .shouldBe(ENABLED); SelenideElement row = getRow(rowBy) .shouldBe(visible); row.click(); return row; }
Example 14
Source File: N2oStandardTableHeader.java From n2o-framework with Apache License 2.0 | 5 votes |
@Override public void click() { SelenideElement elm = element().$(".n2o-checkbox"); if (elm.exists()) elm.click(); else element().$("a").should(Condition.exist).click(); }
Example 15
Source File: N2oSlider.java From n2o-framework with Apache License 2.0 | 5 votes |
private void val(SelenideElement element, String value, int step) { String current = element.getAttribute("aria-valuenow"); int dif = (Integer.parseInt(current) - Integer.parseInt(value)) / step; Keys keys = dif > 0 ? Keys.ARROW_LEFT : Keys.ARROW_RIGHT; element.click(); for (int i = 0; i < Math.abs(dif); i++) element.sendKeys(keys); }
Example 16
Source File: N2oSelect.java From n2o-framework with Apache License 2.0 | 4 votes |
@Override public void expandPopUpOptions() { SelenideElement elm = element().$(".n2o-popup-control"); if (!elm.is(Condition.cssClass("isExpanded"))) elm.click(); }
Example 17
Source File: N2oInputSelect.java From n2o-framework with Apache License 2.0 | 4 votes |
@Override public void collapsePopUpOptions() { SelenideElement elm = element().$(".n2o-popup-control"); if (elm.is(Condition.cssClass("isExpanded"))) elm.click(); }
Example 18
Source File: N2oInputSelect.java From n2o-framework with Apache License 2.0 | 4 votes |
@Override public void expandPopUpOptions() { SelenideElement elm = element().$(".n2o-popup-control"); if (!elm.is(Condition.cssClass("isExpanded"))) elm.click(); }
Example 19
Source File: N2oSelect.java From n2o-framework with Apache License 2.0 | 4 votes |
@Override public void collapsePopUpOptions() { SelenideElement elm = element().$(".n2o-popup-control"); if (elm.is(Condition.cssClass("isExpanded"))) elm.click(); }