当我显示一个对话框时,抛出exception“UnhandledAlertException:Modal dialog present”

我使用Internet Explorer 9使用Selenium Webdriver 2.42.2登录网站。 当我输入凭据并按下登录按钮时,会弹出一个modal dialog,说: 您已登录到同一物理设备。 您是否希望从之前的登录和登录再次注销? 所以有2个选项是/否。 我已经使用了driver.switchTo().alert.accept()但是警报在出现后很快就会消失,只需几分之一秒。 它没有按下Yes按钮。 我的代码: public class launch{ public static void main(Sting args[]){ driver.findElement(By.id(“login”)).click();// click performed launch obj = new launch(); if(obj.isAlertPresent(driver) == true) { Thread.sleep(3000); driver.switchTo().alert(); String a = driver.getTitle(); System.out.println(a); } } public boolean isAlertPresent(WebDriver drive) throws InterruptedException { try { Thread.sleep(2000); drive.switchTo().alert(); Thread.sleep(2000); return […]

我从日历对象中获取WEEK_OF_YEAR时遇到问题

我从日历对象中获取WEEK_OF_YEAR时遇到问题。 by passing date ’31-Dec-2014′: calendar1.get(Calendar.WEEK_OF_YEAR) – return 1 by passing date ’31-Dec-2015′ calendar1.get(Calendar.WEEK_OF_YEAR) – return 53 by passing date ’31-Dec-2016′ calendar1.get(Calendar.WEEK_OF_YEAR) – return 52 by passing date ’31-Dec-2017′ calendar1.get(Calendar.WEEK_OF_YEAR) – return 52 by passing date ’31-Dec-2018′ calendar1.get(Calendar.WEEK_OF_YEAR) – return 1 每次它返回不同的值。 你能帮我解决这个问题吗? 代码如下。 Calendar calendar1 = Calendar.getInstance(); calendar1.setTime(’31-Dec-2012′); calendar1.set(Calendar.HOUR_OF_DAY, 0); calendar1.setFirstDayOfWeek(Calendar.MONDAY);

XStream不会调用readObject()

我有这样建模的代码: class A { private transient Foo foo = new Foo(); private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); foo = new Foo(); } } class B extends A {} 我将readObject()添加到A中,以便在反序列化期间,将初始化瞬态foo 。 但是,我在代码中遇到了断点,并且可以看到XStream根本没有调用readObject()。 我也尝试在类B中使用readObject()来调用A中的initFoo()函数,但这也不起作用。 网站上的常见问题解答似乎并不意味着任何其他样板是必要的。 为什么不被召唤?

在windows-10上的cygwin上阅读java中的EOF

我在cygwin上使用java实用程序(antlr),java是windows版本,我从cygwin bash运行javac / java。 以下java代码用于在win8.1上运行cygwin,从stdin到EOF读取一系列数字(改编自java中的读取输入到EOF ): import java.util.Scanner; public class Hello { public static void main(String[] args) { System.out.println(“Hello, World”); Scanner in = new Scanner(System.in); int num; while (in.hasNextInt()) { num = in.nextInt(); System.out.printf(“%d\n”,num); } } } 最近我买了一台新的win10笔记本电脑,上面安装了cygwin,它不再用了。 当我按下Ctrl-D时,程序继续等待输入,它不被视为EOF。 经过一些调试(参见windows 10中cygwin中EOF的注释),“stty -a”报告“eof = ^ D; susp = ^ Z”,因此预计Ctrl-D将被视为EOF。 c ++中的以下等效代码按预期工作,可能是因为此代码是使用cygwin本身编译的,因此将^ D视为EOF。 #include int main() […]

如何打印位图像TM-T88V

嗨伙计们我有下一个问题我不能打印我的位图像没有白线每24行。 即我需要打印图像,但这个图像每24行到位有白线。 epson打印机将图像打印到下一格式。 >line 23 01010101000010001010 >line 24 00001000100000000110 >line 25 ——— white line ———— 怎么能删除这该死的白线? Image size width:400px height:73px while (offset < height) { //format ESC* Epson printer String modIMG = new String(new byte[]{0x1B, 0x2A, 33, 0, 2}); img.append(modIMG); for (int x = 0; x < width; ++x) { for (int k = 0; […]

Java在cmd中运行,但不在PowerShell中运行

我刚刚将java文件夹添加到我的环境变量中。 当我尝试从Windows命令行(cmd)执行javac HelloWorld.java和java HelloWorld ,它会正常执行。 但是,如果我打开Windows Powershell并执行相同操作,它会说: javac : The term ‘javac’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check t he spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + javac HelloWorld.java […]

如何在Java程序中包含JavaScript文件

我有使用phantomjs创建的脚本文件 var webPage = require(‘webpage’); var page = webPage.create(); page.open(URL, function (status) { var content = page.content; console.log(‘Content: ‘ + content); phantom.exit(); }); 现在我想在Java程序中使用这个脚本,但我不能。 我在我的项目中这样做 ScriptEngineManager s = new ScriptEngineManager(); ScriptEngine se = s.getEngineByName(“JavaScript”); se.eval(new FileReader(“myScript.js”)); 但是这就是结果 Exception in thread “main” javax.script.ScriptException: sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: “require” is not defined. (#1) in at line number 1 at […]

Android IllegalStateException:Fragment null必须是要从实例状态正确重新创建的公共静态类

我从我的Android应用程序中得到以下exception: FATAL EXCEPTION: main java.lang.IllegalStateException: Fragment null must be a public static class to be properly recreated from instance state. at android.support.v4.app.BackStackRecord.doAddOp(BackStackRecord.java:435) at android.support.v4.app.BackStackRecord.add(BackStackRecord.java:420) at android.support.v4.app.FragmentStatePagerAdapter.instantiateItem(FragmentStatePagerAdapter.java:123) at android.support.v4.view.ViewPager.addNewItem(ViewPager.java:1006) at android.support.v4.view.ViewPager.populate(ViewPager.java:1154) at android.support.v4.view.ViewPager.populate(ViewPager.java:1088) at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1614) at android.view.View.measure(View.java:15525) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4825) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404) at android.widget.LinearLayout.measureVertical(LinearLayout.java:695) at android.widget.LinearLayout.onMeasure(LinearLayout.java:588) at android.view.View.measure(View.java:15525) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4825) at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:135) at android.view.View.measure(View.java:15525) at […]

使用Timer在JTextArea中实现打字机效果?

我正在制作一个文本冒险游戏,并遇到了一个问题,我无法以我想要的方式显示我的一些文本。 当输入一些单词时,玩家可以开始引入新房间。 我希望这个介绍有“打字机”的效果。 此事件需要在我的程序ActionPerformed方法中进行。 例如,当用户键入“Move”然后按Enter键时,我希望生成的文本一次打印一个字符。 以下是我在ActionPerformed之外使用的当前方法来实现此效果: public void slowPrint(String message, long millisPerChar) { //makes it so that the player cannot input while the text is being displayed userinput.setEditable(false); String o; for (int i = 0; i < message.length(); i++) { //adds each letter one-by-one o = "" + message.charAt(i); output.append(o); //moves the JTextArea to the […]

更新Tomcat LIb文件夹

我有一个使用Jersey插件开发并部署在Tomact 7上的应用程序。 我必须将项目中使用的所有jar导出到Tomact的lib /文件夹..但我不想..是否可以部署我的应用程序而不将jar导出到Tomcat lib文件夹。 如果是,那么如何? https://t1.ap01.aws.af.cm/rest/person 这是我的应用程序链接,如果未导出lib /,则会出现以下错误: HTTP Status 404 – Servlet Jersey REST Service is not available type Status report message Servlet Jersey REST Service is not available description The requested resource (Servlet Jersey REST Service is not available) is not available. Apache Tomcat/6.0.35