使用java中的selenium webdriver登录Gmail

import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; public class NewGmail { public static void main(String[] args) { WebDriver driver = new FirefoxDriver(); driver.manage().window().maximize(); String url = “https://accounts.google.com/signin”; driver.get(url); driver.findElement(By.id(“identifierId”)).sendKeys(“cp8805”); //driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); WebDriverWait wait=new WebDriverWait(driver, 20); driver.findElement(By.xpath(“//span[@class=’RveJvd snByac’]”)).click(); driver.manage().timeouts().implicitlyWait(40, TimeUnit.SECONDS); driver.findElement(By.xpath(“//input[@class=’whsOnd zHQkBf’]”)).sendKeys(“xxxxxx”); driver.findElement(By.xpath(“//span[@class=’RveJvd snByac’]”)).click(); } } 在邮件ID之后,我的密码也会写入id框选项并且服务器重定向到下一个密码页面。 我想问一下我将做什么,以便我的密码只能输入密码页面。

RESTEasy:找不到内容类型application / json类型的writer

我有一个使用(application / json)并生成(application / json)的restful服务(post)。 此服务的单个参数是带注释的java对象。 我正在使用org.jboss.resteasy.client.ClientRequest将请求发送到服务。 但是,我在客户端和exception中得到此exception: 找不到内容类型application / json类型的writer。 这是否意味着我缺少一些图书馆jar子,或者我必须为application / json编写自己的编写器? 我正在使用resteasy 2.3.3.Final 以下是我添加到我的pom中的各种依赖项,我认为可能与之相关: org.jboss.resteasy resteasy-jaxrs 2.3.3.Final com.fasterxml.jackson.jaxrs jackson-jaxrs-json-provider 2.0.5 org.jboss.resteasy resteasy-jaxb-provider 2.3.4.Final org.jboss.resteasy resteasy-jackson-provider 2.3.4.Final org.codehaus.jackson jackson-core-asl 1.3.0 org.codehaus.jackson jackson-mapper-asl 1.3.0 马特

Java中的树实现(root,父级和子级)

我需要创建一个类似于Java中附加图像的树结构。 我发现了一些与此相关的问题,但我没有找到令人信服且解释清楚的答案。 应用业务包括食品超级类别(主菜,甜点和其他)。 这些类别中的每一个都可以包含父项或子项等。

使用Spring IoC和JavaConfig配置AspectJ方面?

根据Spring的文档使用Spring IoC配置AspectJ方面以配置Spring IOC的方面,必须在xml配置中添加以下内容: 正如@SotiriosDelimanolis所建议的那样,在JavaConfig中将以下内容重写为: @Bean public com.xyz.profiler.Profiler profiler() { com.xyz.profiler.Profiler profiler = com.xyz.profiler.Profiler.aspectOf(); profiler.setProfilingStrategy(jamonProfilingStrategy()); // assuming you have a corresponding @Bean method for that bean return profiler; } 但是,如果Profiler方面是用native aspectj .aj语法编写的,这似乎只能起作用。 如果它是用Java编写的并使用@Aspect注释,则会收到以下错误消息: 对于类型Profiler,方法aspectOf()未定义 对于使用@AspectJ语法编写的方面,是否有使用JavaConfig编写此方法的等效方法?

每次进行更改时都必须重新启动tomcat

每次在java代码中进行小的更改时,有没有办法重新启动tomcat?

如何在jtable中使不可编辑的单元格变灰?

我想在JTable中灰​​化不可编辑的单元格。 我正在使用这样的TableCellRenderer: TableColumn column = table.getColumnModel().getColumn(0); column.setCellRenderer(new GrayableCheckboxCellRenderer()); public class GrayableCheckboxCellRenderer extends JCheckBox implements TableCellRenderer { public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int vRowIndex, int vColIndex) { boolean editable = isEditable(vRowIndex, vColIndex); setBackground(editable ? UIManager.getColor(“Label.background”) : Color.LIGHT_GRAY); setSelected((Boolean) value); if (isSelected) { // TODO: cell (and perhaps other cells) are selected, […]

从Java执行外部程序

我正在尝试从Java代码执行程序。 这是我的代码: public static void main(String argv[]) { try { String line; Process p = Runtime.getRuntime().exec( “/bin/bash -c ls > OutputFileNames.txt”); BufferedReader input = new BufferedReader( new InputStreamReader(p.getInputStream())); while ((line = input.readLine()) != null) { System.out.println(line); } input.close(); } catch (Exception err) { err.printStackTrace(); } } 我的操作系统是Mac OS X 10.6。 如果我从getRuntime().exec()方法中删除”> OutputFileNames.txt” ,则所有文件名都会在控制台上打印出来。 但我需要将它打印到文件中。 另外,如果我将命令更改为: […]

动态线程池

我有一个长时间运行的过程,它监听事件并进行一些密集的处理。 目前我使用Executors.newFixedThreadPool(x)来限制并发运行的作业数,但是根据一天中的时间和其他各种因素,我希望能够动态增加或减少并发线程数。 如果我减少并发线程的数量,我希望当前正在运行的作业能够很好地完成。 是否有一个Java库可以让我控制并动态增加或减少在线程池中运行的并发线程数? (该类必须实现ExecutorService)。 我必须自己实施吗?

如何在java中下载没有内存问题的大文件

当我尝试从服务器下载260MB的大文件时,我收到此错误: java.lang.OutOfMemoryError: Java heap space. 我确信我的堆大小小于252MB。 有没有办法在不增加堆大小的情况下下载大文件? 如何在不出现此问题的情况下下载大文件? 我的代码如下: String path= “C:/temp.zip”; response.addHeader(“Content-Disposition”, “attachment; filename=\”test.zip\””); byte[] buf = new byte[1024]; try { File file = new File(path); long length = file.length(); BufferedInputStream in = new BufferedInputStream(new FileInputStream(file)); ServletOutputStream out = response.getOutputStream(); while ((in != null) && ((length = in.read(buf)) != -1)) { out.write(buf, 0, (int) […]

哪个实时(RTSJ)JVM最受欢迎?

似乎只有少数JVM是Java实时规范(RTSJ)的实现 。 Sun / Oracle Java实时系统超过6000美元,IBM的实时WebSphere超过7000美元,因此许多Java开发人员可能永远不会有机会使用它们中的任何一个。 Oracle的JRockit似乎是一个免费的实时Java实现,具有可预测的,确定性的行为,虽然我不确定,因为他们的文档在营销语言上相当沉重。 由于小型组织开发并具有较小的用户群,其他较小的实时JVM似乎存在风险。 哪些实时JVM更受欢迎? 开发人员最常使用,信任和喜爱哪些?