自动化脚本-在新增产品的时候 无法点击底部的完成按钮,几种方法总结如下:
1 //点击完成按钮方法1 2 // Actions action = new Actions(driver); 3 // WebElement Element2 = Common.scrollToElement(driver,By.xpath("//*[@id='productDetailAddForm']/div/div[18]/button")); 4 // action.moveToElement(Element2).click().perform(); 5 ***************************************** 6 //点击完成按钮一般方法 7 // Thread.sleep(3000); 8 // Common.scrollToElement(driver,By.xpath("//*[@id='productDetailAddForm']/div/div[18]/button")).click(); 9 ****** ****************************************************** 10 /* 点击完成按钮方法2 11 WebElement h = Common.scrollToElement(driver, By.className("//ng-scope")); 12 WebElement head = h.findElement(By.id("productDetailAddForm")); 13 head.findElement(By.xpath("//div/div[18]")).click(); 14 */ 15 ********************************************************************************** 16 //完成按钮在页面底端,一般方法无法实现点击,所以改为以下实现点击完成 17 WebElement Element = Common.scrollToElement(driver,By.xpath("//*[@id='productDetailAddForm']/div/div[18]/button")); 18 Element.sendKeys(Keys.ARROW_DOWN); 19 if(!Element.isSelected()) { 20 Element.click(); 21 Thread.sleep(1000); 22 }