????λ?????????? >> ??????????
Selenium webdriver - ???JS
???????????? ???????[ 2014/5/8 11:36:19 ] ????????Selenium ???????????? js????
???????????????js???????????
??????????????????????????alert?????
1 import org.openqa.selenium.JavascriptExecutor;
2 import org.openqa.selenium.WebDriver;
3 import org.openqa.selenium.firefox.FirefoxDriver;
4
5 public class JavaScript {
6
7 public static void main(String[] args) {
8 WebDriver driver = new FirefoxDriver();
9 // ???js????
10 // 1.??driver???????JavascriptExecutor????
11 // 2.????executeScript????
12 ((JavascriptExecutor)driver).executeScript("alert("hello??this is a alert!")");
13 }
14 }
|
???????????JS???????е???????????selenium
????????????????JS????return document.title ????????title???????selenium???????????????????- -#??
1 import org.openqa.selenium.WebDriver;
2 import org.openqa.selenium.firefox.FirefoxDriver;
3 import org.openqa.selenium.JavascriptExecutor;
4
5
6 public class JavaScript2 {
7
8 public static void main(String[] args) {
9 WebDriver driver = new FirefoxDriver();
10 driver.get("http://www.baidu.com/");
11 /*
12 * ?????????????????
13 * ?÷???????????org.openqa.selenium.JavascriptExecutor?μ????JavascriptExecutor
14 ??????com.gargoylesoftware.htmlunit.javascript.background.JavaScriptExecutor???????
15 JavaScriptExecutor????
16 ????????Java??s???Сд
17 */
18 // ????JavaScriptExecutor
19 JavascriptExecutor js = (JavascriptExecutor)driver;
20 // ???js????????title ?????return
21 String title = (String) js.executeScript("return document.title");
22 System.out.println(title);
23 driver.close();
24 }
25 }
|
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????
??????
????????????????AutoRunner??Selenium????????Selenium???????????????????????Selenium?????????????Щ?????????????????£???????Selenium???????????????ζ?Selenium???????????????????Selenium???????????????????????з?????Щ??????????????????????ATF???Selenium??????????????????д???????Selenium?????????????Selenium????????????????????Selenium???????????ATF????θ??????????????????????Selenium??????????????ATFJava?汾??Selenium??????????UI???-Python+Selenium???????Selenium????Webdriver??????????????????η???Selenium?????????Selenium FF WebDriver?????????firebug??2????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11????????
?????????App Bug???????????????????????Jmeter?????????QC??????APP????????????????app?????е????????jenkins+testng+ant+webdriver??????????????JMeter????HTTP???????Selenium 2.0 WebDriver ??????