Skip to content

Commit 8ed2d9f

Browse files
[py] used pathlib module to check if the file exist in remote/file_detector.py (#12253)
[py] used pathlib module to check if the file exist in remote/file_detector.py Co-authored-by: Diego Molina <diemol@users.noreply.github.com>
1 parent ccdbd04 commit 8ed2d9f

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

py/selenium/webdriver/remote/file_detector.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
import os
1918
from abc import ABCMeta
2019
from abc import abstractmethod
20+
from pathlib import Path
2121
from typing import Optional
2222

2323
from selenium.types import AnyKey
@@ -45,13 +45,5 @@ class LocalFileDetector(FileDetector):
4545

4646
def is_local_file(self, *keys: AnyKey) -> Optional[str]:
4747
file_path = "".join(keys_to_typing(keys))
48-
49-
if not file_path:
50-
return None
51-
52-
try:
53-
if os.path.isfile(file_path):
54-
return file_path
55-
except Exception:
56-
pass
57-
return None
48+
path = Path(file_path)
49+
return file_path if path.is_file() else None

0 commit comments

Comments
 (0)