java+selenium——语法简介

Method Name:方法名,使用任何类的任何方法,我们都需要创建创建类的对象,然后对象可以申请类的素有公共方法(publicmethods)

Return Type:返回的数据类型:方法能够返回一个值或者返回空(void)。

Parameter:参数,数据类型:传递到方法内进行操作的变量。传递的参数必须保持和方法内要求的相同的数据类型。

Get命令

get(String arg0):void---这个方法可以在当前的浏览器窗口加载一个新的页面。接收字符串的参数并且放回值为空。

命令写法---driver.get(Url);

Url即需要加载的网页地址。

driver.get(“http://www.baidu.com”);

或者

String uRL = http://www.baidu.com;

driver.get(uRL);

Get Current URL 命令

getCurrentUrl():String---获取当前浏览器的URL。无参,返回字符串。

命令写法---driver.getCurrentTitle();

 

driver.getCurrentUrl();

或者

String title = driver.getCurrentTitle();

Get Page Source 命令

getPageSource():String --- 用次方法可以获取网页的源码。无参,返回字符串。

命令写法---driver.getPageSource();

driver.getPageSource();

或者

String pageSource = driver.getPageSource();

猜你喜欢

转载自www.cnblogs.com/xiaobaibailongma/p/12214723.html