本文整理汇总了Java中org.openqa.selenium.NoSuchSessionException类的典型用法代码示例。如果您正苦于以下问题:Java NoSuchSessionException类的具体用法?Java NoSuchSessionException怎么用?Java NoSuchSessionException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NoSuchSessionException类属于org.openqa.selenium包,在下文中一共展示了NoSuchSessionException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: longPress
import org.openqa.selenium.NoSuchSessionException; //导入依赖的package包/类
/**
* @author wasiq.bhamla
* @since 26-Apr-2017 8:54:58 PM
*/
public void longPress () {
DeviceChecker.checkDeviceElementEnabled (this.element, this.name);
log.info (String.format ("Performing long press on element [%s]...", this.name));
try {
final int beforeTap = this.device.getSetting ()
.getDelayBeforeTap ();
final int afterTap = this.device.getSetting ()
.getDelayAfterTap ();
this.touch.waitAction (ofSeconds (beforeTap))
.longPress (this.element)
.waitAction (ofSeconds (afterTap))
.perform ();
}
catch (final NoSuchSessionException e) {
fail (AppiumServerStoppedError.class, SERVER_STOPPED, e);
}
}
示例2: tap
import org.openqa.selenium.NoSuchSessionException; //导入依赖的package包/类
/**
* @author wasiq.bhamla
* @since 12-May-2017 10:08:55 PM
*/
public void tap () {
DeviceChecker.checkDeviceElementEnabled (this.element, this.name);
log.info (String.format ("Tapping on element [%s]...", this.name));
try {
final int beforeTap = this.device.getSetting ()
.getDelayBeforeTap ();
final int afterTap = this.device.getSetting ()
.getDelayAfterTap ();
this.touch.waitAction (ofSeconds (beforeTap))
.tap (this.element)
.waitAction (ofSeconds (afterTap))
.perform ();
}
catch (final NoSuchSessionException e) {
fail (AppiumServerStoppedError.class, SERVER_STOPPED, e);
}
}
示例3: webGet2
import org.openqa.selenium.NoSuchSessionException; //导入依赖的package包/类
public static void webGet2(WebDriver webDriver, String url) {
try {
webDriver.get(url);
webGet2(webDriver, url);
} catch (Exception e) {
// e.printStackTrace();
if (e instanceof NoSuchSessionException) {
System.out.println("浏览器关闭,程序退出");
System.exit(0);
}
/*
* try { Thread.sleep(100); } catch (InterruptedException e1) {
* e1.printStackTrace(); } JavascriptExecutor js =
* (JavascriptExecutor) webDriver;
* js.executeScript("window.stop();");
* System.out.println("已停止加载页面》》》》》》》》》》》》》》》》》》》》》》》》");
*/
}
}
示例4: captureScreen
import org.openqa.selenium.NoSuchSessionException; //导入依赖的package包/类
@Override
public byte[] captureScreen() {
if (driver == null) {
return null;
}
if (!(driver instanceof TakesScreenshot)) {
return null;
}
try {
return ((TakesScreenshot) driver)
.getScreenshotAs(OutputType.BYTES);
} catch (NoSuchSessionException e) {
// just do nothing if WebDriver instance is in invalid state
return null;
}
// TODO test should not fail when taking screen capture fails?
}
示例5: captureScreen
import org.openqa.selenium.NoSuchSessionException; //导入依赖的package包/类
@Override
public byte[] captureScreen() {
if (fluent == null) {
return null;
}
WebDriver driver = fluent.getDriver();
if (driver == null) {
return null;
}
if (!(driver instanceof TakesScreenshot)) {
return null;
}
try {
return ((TakesScreenshot) driver)
.getScreenshotAs(OutputType.BYTES);
} catch (NoSuchSessionException e) {
// just do nothing if WebDriver instance is in invalid state
return null;
}
}
示例6: appendText
import org.openqa.selenium.NoSuchSessionException; //导入依赖的package包/类
/**
* @author wasiq.bhamla
* @since Oct 21, 2017 5:22:04 PM
* @param text
*/
public void appendText (final String text) {
DeviceChecker.checkDeviceElementEnabled (this.element, this.name);
tap ();
log.info (String.format ("Appending text [%s] in element [%s]...", text, this.name));
try {
this.element.sendKeys (text);
}
catch (final NoSuchSessionException e) {
fail (AppiumServerStoppedError.class, SERVER_STOPPED, e);
}
}
示例7: clear
import org.openqa.selenium.NoSuchSessionException; //导入依赖的package包/类
/**
* @author wasiq.bhamla
* @since 26-Apr-2017 8:49:52 PM
*/
public void clear () {
DeviceChecker.checkDeviceElementEnabled (this.element, this.name);
log.info (String.format ("Clearing element [%s]...", this.name));
try {
this.element.clear ();
}
catch (final NoSuchSessionException e) {
fail (AppiumServerStoppedError.class, SERVER_STOPPED, e);
}
}
示例8: enabled
import org.openqa.selenium.NoSuchSessionException; //导入依赖的package包/类
/**
* @author wasiq.bhamla
* @since 26-Apr-2017 8:51:07 PM
* @return enabled
*/
public boolean enabled () {
log.info (String.format ("Checking if element [%s] is enabled...", this.name));
try {
return this.element.isEnabled ();
}
catch (final NoSuchSessionException e) {
fail (AppiumServerStoppedError.class, SERVER_STOPPED, e);
}
return false;
}
示例9: enterText
import org.openqa.selenium.NoSuchSessionException; //导入依赖的package包/类
/**
* @author wasiq.bhamla
* @since 26-Apr-2017 8:31:45 PM
* @param text
*/
public void enterText (final String text) {
DeviceChecker.checkDeviceElementEnabled (this.element, this.name);
tap ();
clear ();
log.info (String.format ("Entering text [%s] in element [%s]...", text, this.name));
try {
this.element.sendKeys (text);
}
catch (final NoSuchSessionException e) {
fail (AppiumServerStoppedError.class, SERVER_STOPPED, e);
}
}
示例10: pinch
import org.openqa.selenium.NoSuchSessionException; //导入依赖的package包/类
/**
* @author wasiq.bhamla
* @since 26-Apr-2017 8:49:08 PM
*/
public void pinch () {
DeviceChecker.checkDeviceElementEnabled (this.element, this.name);
log.info (String.format ("Pinching on element [%s]...", this.name));
try {
fail (NotImplementedError.class, "Pinch! Coming Soon!!");
}
catch (final NoSuchSessionException e) {
fail (AppiumServerStoppedError.class, SERVER_STOPPED, e);
}
}
示例11: selected
import org.openqa.selenium.NoSuchSessionException; //导入依赖的package包/类
/**
* @author wasiq.bhamla
* @since 26-Apr-2017 8:50:40 PM
* @return selected
*/
public boolean selected () {
log.info (String.format ("Checking if element [%s] is selected...", this.name));
try {
return this.element.isSelected ();
}
catch (final NoSuchSessionException e) {
fail (AppiumServerStoppedError.class, SERVER_STOPPED, e);
}
return false;
}
示例12: submit
import org.openqa.selenium.NoSuchSessionException; //导入依赖的package包/类
/**
* @author wasiq.bhamla
* @since 06-May-2017 4:56:42 PM
*/
public void submit () {
DeviceChecker.checkDeviceElementEnabled (this.element, this.name);
log.info (String.format ("Performing submit on element [%s]...", this.name));
try {
this.element.submit ();
}
catch (final NoSuchSessionException e) {
fail (AppiumServerStoppedError.class, SERVER_STOPPED, e);
}
}
示例13: swipe
import org.openqa.selenium.NoSuchSessionException; //导入依赖的package包/类
/**
* @author wasiq.bhamla
* @since 12-May-2017 10:07:14 PM
* @param direction
*/
public void swipe (final SwipeDirection direction) {
DeviceChecker.checkDeviceElementEnabled (this.element, this.name);
log.info (String.format ("Swiping [%s] on element [%s]...", direction, this.name));
try {
fail (NotImplementedError.class, "Swipe! Coming Soon!!");
}
catch (final NoSuchSessionException e) {
fail (AppiumServerStoppedError.class, SERVER_STOPPED, e);
}
}
示例14: text
import org.openqa.selenium.NoSuchSessionException; //导入依赖的package包/类
/**
* @author wasiq.bhamla
* @since 26-Apr-2017 8:52:40 PM
* @return text
*/
public String text () {
log.info (String.format ("Getting text on element [%s]...", this.name));
try {
return this.element.getText ();
}
catch (final NoSuchSessionException e) {
fail (AppiumServerStoppedError.class, SERVER_STOPPED, e);
}
return null;
}
示例15: visible
import org.openqa.selenium.NoSuchSessionException; //导入依赖的package包/类
/**
* @author wasiq.bhamla
* @since 26-Apr-2017 8:51:40 PM
* @return visible
*/
public boolean visible () {
log.info (String.format ("Checking if element [%s] is visible...", this.name));
try {
return this.element.isDisplayed ();
}
catch (final NoSuchSessionException e) {
fail (AppiumServerStoppedError.class, SERVER_STOPPED, e);
}
return false;
}