実現したいこと
html
1<div class="first second"> 2 <p>get text</p> 3</div> 4<div class="first second third"> 5 <p>not get text</p> 6</div>
上記のようなクラス定義されているhtmlで class="first second third"
の<p>内のnot get text
は取得せず、class="first second"
の<p>内のテキスト get text
のみをCSSセレクタで取得したい。
発生している問題・分からないこと
下記のコードだと、get text
とnot get text
の両方が出力されてしまいます。どうすれば、get text
のみを取得できますでしょうか?
該当のソースコード
python
1elements = driver.find_elements(By.CSS_SELECTOR, ".first.second :not(.third)") 2for element in elements: 3 print(element.text)

回答1件
あなたの回答
tips
プレビュー