質問編集履歴
3
タイトルのミス修正
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
Seleniumのfind_elementsで
|
1
|
+
Seleniumのfind_elementsで特定の子要素のclassだけを除外する方法
|
test
CHANGED
File without changes
|
2
条件の補足と不要なテキストの削除
test
CHANGED
File without changes
|
test
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
</div>
|
9
9
|
```
|
10
10
|
|
11
|
-
上記のようなクラス定義されているhtmlで `class="first second third"`の<p>内の
|
11
|
+
上記のようなクラス定義されているhtmlで `class="first second third"`の<p>内の`not get text`は取得せず、`class="first second"` の<p>内のテキスト `get text` のみをCSSセレクタで取得したい。
|
12
12
|
|
13
13
|
### 発生している問題・分からないこと
|
14
14
|
|
@@ -20,19 +20,8 @@
|
|
20
20
|
### 該当のソースコード
|
21
21
|
|
22
22
|
```python
|
23
|
-
elements = driver.find_elements(By.CSS_SELECTOR, ".first.second :not(.third)"
|
23
|
+
elements = driver.find_elements(By.CSS_SELECTOR, ".first.second :not(.third)")
|
24
24
|
for element in elements:
|
25
25
|
print(element.text)
|
26
26
|
```
|
27
27
|
|
28
|
-
### 試したこと・調べたこと
|
29
|
-
- [x] teratailやGoogle等で検索した
|
30
|
-
- [x] ソースコードを自分なりに変更した
|
31
|
-
- [ ] 知人に聞いた
|
32
|
-
- [ ] その他
|
33
|
-
|
34
|
-
##### 上記の詳細・結果
|
35
|
-
not文を色々と調べて `>`を付けるなど試しましたが、あまり上手くいかず、CSSセレクタも初心者なため教えていただけると助かります。
|
36
|
-
|
37
|
-
### 補足
|
38
|
-
特になし
|
1
条件の説明の補足
test
CHANGED
File without changes
|
test
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
</div>
|
9
9
|
```
|
10
10
|
|
11
|
-
上記のようなクラス定義されているhtmlで `class="first second"` の<p>内のテキスト `get text` のみをCSSセレクタで取得したい。
|
11
|
+
上記のようなクラス定義されているhtmlで `class="first second third"`の<p>内のテキストは取得せず、`class="first second"` の<p>内のテキスト `get text` のみをCSSセレクタで取得したい。
|
12
12
|
|
13
13
|
### 発生している問題・分からないこと
|
14
14
|
|