0
我想獲得文本框工具提示(Gmail的創建帳戶密碼字段)的信息,但我無法處理這種情況。如何獲取gmail創建帳戶密碼字段ToolTip信息使用web驅動程序硒
我使用Selenium WebDriver(java)。請從下面的代碼,我用什麼:
WebDriver wd = new FirefoxDriver();
wd.navigate().to("https://accounts.google.com/SignUp?service=mail&continue=https%3A%2F%2Fmail.google.com%2Fmail%2F%3Ftab%3Dwm&hl=en");
WebElement NewButton = wd.findElement(By.xpath(".//*[@id='Passwd']"));
NewButton.click();
String Tooltip = NewButton.getText();
/*String Tooltip = NewButton.getAttribute("title"); // used this getattribute method also */
System.out.println(Tooltip);
我用其他的方法也類似這樣的方法,但不能正常工作&沒有顯示在控制檯的任何錯誤也。
請看以下方法也:
//2nd method
/*Actions ActionChains = new Actions(wd);
WebElement NewButton = wd.findElement(By.xpath(".//*[@id='Passwd']"));
ActionChains.clickAndHold(NewButton).build().perform();
System.out.println("hold");
String Tooltip = NewButton.getText();
String Tooltip = NewButton.getAttribute("title");
System.out.println("done");
System.out.println(Tooltip);*/
//3rd method
/*String tooltip=wd.findElement(By.xpath(".//*[@id='Passwd']")).getAttribute("title");
System.out.println(tooltip);
System.out.println("Done");*/
//4th method
/*WebElement ToolTip = wd.findElement(By.xpath(".//*[@id='Passwd']"));
System.out.println(ToolTip.getText());
System.out.println("Done");*/