设置为移动尺寸时,无法单击复选框

时间:2019-01-11 06:45:13

标签: java selenium-webdriver selenium-chromedriver

这是我的代码

System.setProperty("webdriver.chrome.driver", "D:\\Chrome Driver\\chromedriver.exe");
                  driver = new ChromeDriver();
                    Dimension d = new Dimension(400,600);
                     //Resize current window to the set dimension
                             driver.manage().window().setSize(d);
                   driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
JavascriptExecutor jsm=(JavascriptExecutor)driver;
                 jsm.executeScript("window.scrollBy(0,1000)");
                 Thread.sleep(8000);
                 //driver.findElement(By.cssSelector("div.place-order-form > form:nth-child(1) > div:nth-child(1) > label:nth-child(1) > input:nth-child(1)"));
                 WebElement element = driver.findElement(By.xpath("//div[@class='place-order-form hidden-xs']/form[@id='placeOrderForm1']/div/label/input[@id='Terms1']"));
                 jsm.executeScript("arguments[0].click();", element);
                 //driver.findElement(By.xpath("//div[@class='place-order-form hidden-xs']/form[@id='placeOrderForm1'`enter code here`]/div/label/input[@id='Terms1']")).click();
                 driver.findElement(By.id("placeOrder")).click();
                 }

此处一切正常,但在最大化能够单击复选框但无法处理指定尺寸的窗口时单击接受条款复选框 有人可以帮忙吗 预先感谢

0 个答案:

没有答案