このXPathは正しいです。
//span[contains(@class,'summary')]
//span[@class='summary']
私はPythonの男ですが、私はJavaに変換しました。あなたは行うことができます。
element = driver.findElement(By.name("summary"));
element = driver.findElement(By.className("summary"));
element = driver.findElement(By.cssSelector('span[class="summary"]');
をそして、あなたは要素のテキストをしたい場合は、すべての要素がメソッド.getText()
、find*
関数は要素のみ/秒を取得していることを覚えておいてください。
複数チェックでdriver.findElements(By.xpath())
を使用していないことを確認してください。その場合は、最初に個々の要素を取得する必要があります。その後、.getText()
メソッドにアクセスします。
description = driver.findElement(By.className("summary")).getText();
System.out.print(description);
代わりにあなたができる:
description = driver.findElement(By.className("summary"));
description_text = description.getAttribute("innerHTML");
System.out.print(description_text);
をあなたの問題はあなたの要素は、(古い)見えたり到達できないということであれば。次に、JavaScriptを使用することができます。言語 https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/WebElement.html
:複数の基準については
? – Jeflopo
私はJavaを使用します。ありがとう –
あなたのxpathは見た目に見えます。あなたは何を意味しますか?それは私にテキストの説明を与えませんか?あなたは何を得ていますか? –