0
イメージのツールヒントテキストを取得しようとしていて、変数に保存したかったのです。以下は、HTML Code.scriptがマウスのホバーイベントを実行し、ツールチップのテキスト値を表示することができますが、ツールチップのテキスト値を取得することができません。セレンウェブドライバを使用してツールヒントテキストを取得する方法
<img onmouseover="var relNo=getReleaseNo(); this.T_ABOVE = false; this.T_OFFSETY=-10; this.T_OFFSETX=10; this.T_WIDTH=200; this.T_DELAY=1000; return escape('<table><tr><td align=center>Welcome to the Daimler EngineeringPortal<br><b>' + relNo + '</b></td></tr></table>');" src="./pics/logo/logo_mini.jpg">
PFA以下はセレンスクリプトです。スクリプトでは、すべてのものがテキストを取得することができないexppectを働いています。
セレンスクリプト
package All_Module_Engp;
import java.io.File;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxBinary;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.interactions.Action;
import org.openqa.selenium.interactions.Actions;
public class Engp_Module {
public static void main(String args[])
{
File pathToBinary = new File("C:/Users/rrimjhi/AppData/Local/Mozilla Firefox/firefox.exe");
FirefoxBinary ffBinary = new FirefoxBinary(pathToBinary);
FirefoxProfile firefoxProfile = new FirefoxProfile();
WebDriver driver = new FirefoxDriver(ffBinary,firefoxProfile);
driver.get("https://tindito.COM");
driver.findElement(By.id("usr")).sendKeys("xyz123");
driver.findElement(By.id("password")).sendKeys("xyz123");
driver.findElement(By.name("login")).click();
driver.manage().window().maximize();
// String s = driver.getTitle();
// System.out.println(s);
Actions tooltip = new Actions(driver);
driver.switchTo().frame("header");
WebElement img1=driver.findElement(By.xpath("//img[@src='./pics/logo/logo_mini.jpg']"));
tooltip.clickAndHold(img1).perform();
String ToolTipText = img1.getText();
System.out.println(ToolTipText);
}
}
ありません、それは – Rimjhim
に動作していない私は、コードが何を行っている見ることができます? –
アクションtooltip =新しいアクション(ドライバ); \t \t \t driver.switchTo()。frame( "header"); \t \t \t WebElement img1 = driver.findElement(By.xpath( "// img [@src = '。/ pics/logo/logo_mini.jpg']")); \t \t tooltip.clickAndHold(img1).perform(); \t \t driver.manage()。timeouts()。implicitlyWait(50、TimeUnit.SECONDS); – Rimjhim