找到關於 Rest Assured 的161 篇文章

如何在 Selenium webdriver 中獲取父元素的標籤名?

Debomita Bhattacharjee
更新於 2021年11月22日 11:38:56

3K+ 次瀏覽

我們可以在 Selenium webdriver 中獲取父元素的標籤名。首先,我們需要使用任何定位器(例如 id、class、name、xpath 或 CSS)來識別子元素。然後,我們需要使用 findElement(By.xpath()) 方法識別父元素。我們可以透過使用子元素定位父元素,然後將 (parent::*) 作為引數傳遞給 findElement(By.xpath()) 方法來識別父元素。接下來,要獲取父元素的標籤名,我們需要使用 getTagName() 方法。語法:child.findElement(By.xpath("parent::*"));讓我們識別下面 html 程式碼中子元素 li 的父元素的標籤名…… 閱讀更多

如何在 Selenium webdriver 中獲取頁面標題?

Debomita Bhattacharjee
更新於 2021年11月22日 11:34:51

10K+ 次瀏覽

我們可以在 Selenium webdriver 中獲取頁面標題。getTitle() 方法用於獲取當前頁面標題,然後我們可以在控制檯中獲取結果。語法:t = driver.getTitle();讓我們查詢當前頁面的標題。我們將得到 About Careers at Tutorials Point – Tutorialspoint 作為輸出。示例程式碼實現。import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import java.util.concurrent.TimeUnit; public class PageTitle{    public static void main(String[] args) {       System.setProperty("webdriver.chrome.driver",       "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe");       //隱式等待       driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);       WebDriver driver = new ChromeDriver(); ... 閱讀更多

如何在 Python 中處理 Selenium Webdriver 中的框架?

Debomita Bhattacharjee
更新於 2021年11月22日 11:21:12

706 次瀏覽

我們可以在 Python 中處理 Selenium webdriver 中的框架。iframe 透過 html 文件中的標籤進行標識。iframe 是一個 html 文件,其中包含位於另一個 html 文件內的元素。讓我們來看一個框架的 html 文件。以下方法有助於在 iframe 之間切換:switch_to.frame(args) – 將框架索引作為引數傳遞給方法。iframe 的起始索引為 0。語法:driver.switch_to.frame(0),切換到第一個 iframe。switch_to.frame(args) - 將框架名稱或 id 作為引數傳遞給方法。語法:driver.switch_to.frame("nm"),切換到名稱為 nm 的 iframe。switch_to.frame(args) - ... 閱讀更多

如何在 Selenium Webdriver 中與隱藏元素互動?

Debomita Bhattacharjee
更新於 2021年11月22日 11:19:22

14K+ 次瀏覽

我們可以在 Selenium Webdriver 中與隱藏元素互動。隱藏元素是指存在於 DOM 中但在頁面上不可見的元素。大多數隱藏元素由 CSS 屬性 style="display:none;" 定義。如果元素是表單標籤的一部分,則可以透過將屬性 type 設定為 hidden 值來隱藏它。Selenium 預設情況下無法處理隱藏元素,在使用它們時會丟擲 ElementNotVisibleException 異常。Javascript Executor 用於處理頁面上的隱藏元素。Selenium 使用 executeScript 方法執行 Javascript 命令。要執行的命令…… 閱讀更多

如何在 Selenium Webdriver 中獲取元素的屬性值?

Debomita Bhattacharjee
更新於 2021年11月22日 11:15:19

7K+ 次瀏覽

我們可以在 Selenium Webdriver 中獲取元素的屬性值。這是藉助 getAttribute 方法實現的。在一個 html 文件中,每個元素都透過其標籤名以及元素屬性及其值來標識。要獲取屬性值,我們必須將元素屬性作為引數傳遞給 getAttribute 方法。讓我們來看一下元素的 html 程式碼並獲取其 src 屬性的值。其 src 屬性的值將為 /about/images/logo.png。示例程式碼實現。import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import java.util.concurrent.TimeUnit; public class ... 閱讀更多

如何在 Selenium Webdriver 中上傳檔案?

Debomita Bhattacharjee
更新於 2021年11月22日 11:00:22

5K+ 次瀏覽

我們可以在 Selenium Webdriver 中上傳檔案。這是透過 sendKeys 方法實現的。我們必須首先識別執行檔案選擇的元素,方法是提及檔案路徑(要上傳的檔案)。這僅適用於具有 type 屬性設定為 file 值以及元素標籤名為 input 的元素。下面的 html 程式碼顯示了 type = file 值設定的元素。示例程式碼實現。import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import java.util.concurrent.TimeUnit; public class WndsFileUpl{    public static void main(String[] args) {       System.setProperty("webdriver.chrome.driver",       "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe");   ... 閱讀更多

使用 Java 快速入門進行 Selenium WebDriver。

Debomita Bhattacharjee
更新於 2021年11月22日 10:56:04

580 次瀏覽

我們可以使用 Java 快速入門模板與 Selenium webdriver 協同工作。這可以透過以下步驟完成:步驟 1 - 點選 Eclipse 中的檔案選單。然後選擇新建選項。然後點選其他。步驟 2 - 從 Maven 資料夾中點選 Maven 專案。然後點選下一步。步驟 3 - 繼續執行後續步驟。步驟 4 - 選擇 maven-archetype-quickstart 模板。然後點選下一步。步驟 5 - 將 GroupId 新增為 Selenium,將 Artifact Id 新增為 Automation-Selenium,然後繼續。步驟 6 - 將建立一個具有原型專案結構的專案。Selenium 相關的指令碼應該在 src/test/java 資料夾中編寫。

如何在 Python 中使用 Selenium 執行 Javascript?

Debomita Bhattacharjee
更新於 2021年11月22日 10:48:51

23K+ 次瀏覽

我們可以在 Python 中使用 Selenium webdriver 執行 Javascript。文件物件模型 (DOM) 透過 Javascript 的幫助與頁面上的元素進行通訊。Selenium 透過使用 execute_script 方法來執行 Javascript 命令。要執行的命令作為引數傳遞給方法。某些操作(例如向下滾動頁面)不能直接透過 Selenium 方法執行。這是藉助 Javascript Executor 實現的。window.scrollTo 方法用於執行滾動操作。要沿 x 軸水平滾動的畫素和要沿 y 軸垂直滾動的畫素…… 閱讀更多

Selenium RC 與 Selenium webdriver 的比較。

Debomita Bhattacharjee
更新於 2021年11月22日 10:46:47

631 次瀏覽

Selenium RC 和 Webdriver 之間的區別如下所示:功能Selenium WebdriverSelenium RC架構不是從 Javascript 獲取的。是從 Javascript 獲取的。伺服器無需伺服器即可開始測試用例執行。需要伺服器才能開始測試用例執行。面向物件廣泛用於面向物件程式設計。適度用於面向物件程式設計。瀏覽器可以測試所有主要的瀏覽器,包括在無頭模式下執行。可以測試所有主要的瀏覽器。警報能夠處理警報。不能處理警報。下拉選單能夠處理下拉選單。不能處理下拉選單。動態定位器可以使用動態定位器定位元素。無法使用動態定位器定位元素。錄製和…… 閱讀更多

如何使用測試執行器檔案執行 Cucumber 測試?

Debomita Bhattacharjee
更新於 2021年11月22日 10:45:09

瀏覽量:16K+

我們可以使用 Cucumber 的測試執行器檔案來執行測試。測試執行器檔案應該包含我們要執行的特徵檔案和步驟定義檔案的路徑。 特徵檔案程式碼實現 特性 - 登入模組 場景 - 歡迎頁面登入驗證 給定 使用者位於歡迎頁面 那麼 歡迎頁面應該顯示 步驟定義檔案程式碼實現 package stepDefinations; import io.cucumber.java.en.Given; import io.cucumber.java.en.Then; public class stepDefination { @Given("^User is on Welcome Page$") public void user_on_welcome_page() { System.out.println("User on welcome page"); } @Then("^Welcome page should be displayed$") public void verify_user_on_welcome_page() { ... 閱讀更多

廣告
© . All rights reserved.