パッケージrjcs。 輸入java.text.SimpleDateFormatの。 輸入はjava.util.ArrayList; インポートのjava.util.Calendar; 輸入はjava.util.List; 輸入java.util.Set; 輸入org.openqa.selenium.interactions.Actions。 輸入org.apache.commons.io.FileUtils。 輸入org.openqa.selenium.TakesScreenshot; 輸入org.openqa.selenium.firefox.FirefoxDriver; 輸入org.openqa.selenium.interactions.Actions。 輸入org.openqa.selenium.By; 輸入org.openqa.selenium.Keys。 輸入org.openqa.selenium.WebElement; 輸入org.testng.annotations.Test; 輸入 org.openqa.selenium *。; 輸入java.awt.Rectangle; 輸入java.awt.Robot。 輸入java.awt.Toolkitの。 輸入java.awt.image.BufferedImage; インポートのjava.io.File; インポートにjava.io.IOException; 輸入javax.imageio.ImageIO; 輸入org.openqa.selenium.OutputType。 輸入com.thoughtworks.selenium.SeleneseTestNgHelper; パブリック クラスckqhh { 公共 静的 ボイドメイン(文字列[]引数) { するSystem.setProperty( "webdriver.firefox.bin"、 "C:\\プログラムファイル(x86の)\\ \\ firefox.exeをMozilla Firefoxの"); // インストールパスのFirefoxを設定し、システムを防止することが見つけることができません FirefoxDriverドライバを = 新しい新しい FirefoxDriver(); // 初期Firefoxブラウザインスタンス、およびブラウザを開いて 試してみる { driver.manage()ウィンドウ()最大化を(); ... // 最大化されたウィンドウ のThread.sleep( 3000 ); driver.manage() .window()を最大();. // ウィンドウ最大化 のThread.sleep( 3000 ); driver.get("https://www.baidu.com" ); のThread.sleep( 1000年); アクションアクション = 新しい新しいアクション(ドライバ); action.moveToElement(driver.findElementByLinkText( "設定")。)()を実行; // ホバー要素が上方に配置され driver.findElementByClassName(クリック();. "はsetPref") // オープン検索設定 のThread.sleep( 8000 ); // リスト内のラジオボタンこれ のArrayList <WebElement> SEARCH_TYPE =(ArrayListを <WebElement> ) driver.findElements(By.xpath( "// * [@ ID = 'SE-settting-2'] / *")); 用(WebElement ELE:SEARCH_TYPE) { ele.click()。 Thread.sleep( 5000 ); } のThread.sleep( 5000 ); } キャッチ(例外e) { e.printStackTrace(); } 最後に { driver.quit()。 } } }
Javaの+ Selenium--ラジオボタン操作
おすすめ
転載: www.cnblogs.com/xiaobaibailongma/p/12216198.html
おすすめ
ランキング