-2
我試圖通過使用Selenium webdriver訪問網頁,但我被卡住以找出元素。找不到selenium webdriver元素
WebElement button3 = driver.findElement(
By.cssSelector(".device-selector-dropdown-child.device-selected"));
我使用CSS,xpath,但他們都沒有工作。
package org.openqa.selenium.chrome;
//import java.util.Scanner;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
//import org.openqa.selenium.JavascriptExecutor;
//import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class marslogin{
static WebDriver driver;
static WebDriver document;
public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.chrome.driver", "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chromedriver.exe");
driver = new ChromeDriver();
//driver = new FirefoxDriver();
driver.get("https://accounts.google.com/ServiceLogin?");
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
//WebElement id = driver.findElement(By.name("username"));
WebElement id = driver.findElement(By.name("Email"));
id.sendKeys("[email protected]");
WebElement button = driver.findElement(By.name("signIn"));
button.click();
WebElement pass = driver.findElement(By.id("Passwd"));
pass.sendKeys("battery123");
WebElement button1 = driver.findElement(By.id("signIn"));
button1.click();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
//driver.get("https://play.google.com/store/apps/collection/topselling_free");
//driver.manage().window().maximize();
driver.get("https://play.google.com/store/apps/details?id=com.facebook.orca");
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
Thread.sleep(1000);
WebElement button2 = driver.findElement(By.xpath("//*[@id='body-content']/div/div/div[1]/div[1]/div/div[1]/div/div[3]/div/div[1]/span/span/span/button[2]"));
button2.click();
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
WebElement button3 = driver.findElement(By.cssSelector(".device-selector-dropdown-child.device-selected"));
button3.click();
//WebElement button4 = driver.findElement(By.xpath("//*[@id='device-selector-container']/div/div/div/button[2]"));
//button4.click();
//WebElement button5 = driver.findElement(By.xpath("//*[@id='purchase-ok-button']"));
// button5.click();
//WebElement button6 = driver.findElement(By.cssSelector("#close-dialog-button"));
//button6.click();
}
從代碼 – drets
@ drets 21刪除個人數據,如gmail地址和密碼,這不是個人數據。它只是測試帳戶。 –
任何人請幫助 –