Trong bài trước, chúng ta đã xem xét kiến trúc cấp cao của các ứng dụng Selenium. Bài đăng này sẽ nói về việc định vị các phần tử trên một trang web để tương tác với chúng Trước tiên chúng ta nên định vị các phần tử trên một trang để thực hiện một số thao tác trên chúng. Chúng ta có thể định vị các phần tử theo thuộc tính id, thuộc tính tên, bộ chọn css, tên lớp, tên thẻ, xpath và văn bản liên kết đầy đủ hoặc một phần chiến lược định vịPython api cung cấp các phương thức sau để tìm các phần tử trên một trang # OutputMail input field placeholder: [email protected] Submit button text: SUBMIT QUESTION Second link text: Hitchhiker’s Guide to Python Python Official link text: Python Official Link text - 1: Python Official Link text - 2: Hitchhiker’s Guide to Python Link text - 3: Dive Into Python Link text - 4: Real Python Link text - 5: Python Subreddit Link text - 6: Talk Python Podcast Link text - 7: Awesome Python Question text area placeholder: Your question... Navigation item - 1: About Navigation item - 2: BOPI Navigation item - 3: Feedback Support button text: Support Me There is no h1 tag in the document! 2# OutputMail input field placeholder: [email protected] Submit button text: SUBMIT QUESTION Second link text: Hitchhiker’s Guide to Python Python Official link text: Python Official Link text - 1: Python Official Link text - 2: Hitchhiker’s Guide to Python Link text - 3: Dive Into Python Link text - 4: Real Python Link text - 5: Python Subreddit Link text - 6: Talk Python Podcast Link text - 7: Awesome Python Question text area placeholder: Your question... Navigation item - 1: About Navigation item - 2: BOPI Navigation item - 3: Feedback Support button text: Support Me There is no h1 tag in the document! 3# OutputMail input field placeholder: [email protected] Submit button text: SUBMIT QUESTION Second link text: Hitchhiker’s Guide to Python Python Official link text: Python Official Link text - 1: Python Official Link text - 2: Hitchhiker’s Guide to Python Link text - 3: Dive Into Python Link text - 4: Real Python Link text - 5: Python Subreddit Link text - 6: Talk Python Podcast Link text - 7: Awesome Python Question text area placeholder: Your question... Navigation item - 1: About Navigation item - 2: BOPI Navigation item - 3: Feedback Support button text: Support Me There is no h1 tag in the document! 4# OutputMail input field placeholder: [email protected] Submit button text: SUBMIT QUESTION Second link text: Hitchhiker’s Guide to Python Python Official link text: Python Official Link text - 1: Python Official Link text - 2: Hitchhiker’s Guide to Python Link text - 3: Dive Into Python Link text - 4: Real Python Link text - 5: Python Subreddit Link text - 6: Talk Python Podcast Link text - 7: Awesome Python Question text area placeholder: Your question... Navigation item - 1: About Navigation item - 2: BOPI Navigation item - 3: Feedback Support button text: Support Me There is no h1 tag in the document! 5# OutputMail input field placeholder: [email protected] Submit button text: SUBMIT QUESTION Second link text: Hitchhiker’s Guide to Python Python Official link text: Python Official Link text - 1: Python Official Link text - 2: Hitchhiker’s Guide to Python Link text - 3: Dive Into Python Link text - 4: Real Python Link text - 5: Python Subreddit Link text - 6: Talk Python Podcast Link text - 7: Awesome Python Question text area placeholder: Your question... Navigation item - 1: About Navigation item - 2: BOPI Navigation item - 3: Feedback Support button text: Support Me There is no h1 tag in the document! 6# OutputMail input field placeholder: [email protected] Submit button text: SUBMIT QUESTION Second link text: Hitchhiker’s Guide to Python Python Official link text: Python Official Link text - 1: Python Official Link text - 2: Hitchhiker’s Guide to Python Link text - 3: Dive Into Python Link text - 4: Real Python Link text - 5: Python Subreddit Link text - 6: Talk Python Podcast Link text - 7: Awesome Python Question text area placeholder: Your question... Navigation item - 1: About Navigation item - 2: BOPI Navigation item - 3: Feedback Support button text: Support Me There is no h1 tag in the document! 7# OutputMail input field placeholder: [email protected] Submit button text: SUBMIT QUESTION Second link text: Hitchhiker’s Guide to Python Python Official link text: Python Official Link text - 1: Python Official Link text - 2: Hitchhiker’s Guide to Python Link text - 3: Dive Into Python Link text - 4: Real Python Link text - 5: Python Subreddit Link text - 6: Talk Python Podcast Link text - 7: Awesome Python Question text area placeholder: Your question... Navigation item - 1: About Navigation item - 2: BOPI Navigation item - 3: Feedback Support button text: Support Me There is no h1 tag in the document! 8# OutputMail input field placeholder: [email protected] Submit button text: SUBMIT QUESTION Second link text: Hitchhiker’s Guide to Python Python Official link text: Python Official Link text - 1: Python Official Link text - 2: Hitchhiker’s Guide to Python Link text - 3: Dive Into Python Link text - 4: Real Python Link text - 5: Python Subreddit Link text - 6: Talk Python Podcast Link text - 7: Awesome Python Question text area placeholder: Your question... Navigation item - 1: About Navigation item - 2: BOPI Navigation item - 3: Feedback Support button text: Support Me There is no h1 tag in the document! 9
Các phương thức này trả về một đối tượng theo kiểu # OutputMail input field placeholder: [email protected] Submit button text: SUBMIT QUESTION Second link text: Hitchhiker’s Guide to Python Python Official link text: Python Official Link text - 1: Python Official Link text - 2: Hitchhiker’s Guide to Python Link text - 3: Dive Into Python Link text - 4: Real Python Link text - 5: Python Subreddit Link text - 6: Talk Python Podcast Link text - 7: Awesome Python Question text area placeholder: Your question... Navigation item - 1: About Navigation item - 2: BOPI Navigation item - 3: Feedback Support button text: Support Me There is no h1 tag in the document! 0 (đại diện cho một nút DOM cụ thể) hoặc tăng # OutputMail input field placeholder: [email protected] Submit button text: SUBMIT QUESTION Second link text: Hitchhiker’s Guide to Python Python Official link text: Python Official Link text - 1: Python Official Link text - 2: Hitchhiker’s Guide to Python Link text - 3: Dive Into Python Link text - 4: Real Python Link text - 5: Python Subreddit Link text - 6: Talk Python Podcast Link text - 7: Awesome Python Question text area placeholder: Your question... Navigation item - 1: About Navigation item - 2: BOPI Navigation item - 3: Feedback Support button text: Support Me There is no h1 tag in the document! 1 nếu không tìm thấyBạn cũng có thể tìm nhiều phần tử với các phiên bản sau của phương thức tìm # OutputMail input field placeholder: [email protected] Submit button text: SUBMIT QUESTION Second link text: Hitchhiker’s Guide to Python Python Official link text: Python Official Link text - 1: Python Official Link text - 2: Hitchhiker’s Guide to Python Link text - 3: Dive Into Python Link text - 4: Real Python Link text - 5: Python Subreddit Link text - 6: Talk Python Podcast Link text - 7: Awesome Python Question text area placeholder: Your question... Navigation item - 1: About Navigation item - 2: BOPI Navigation item - 3: Feedback Support button text: Support Me There is no h1 tag in the document! 2# OutputMail input field placeholder: [email protected] Submit button text: SUBMIT QUESTION Second link text: Hitchhiker’s Guide to Python Python Official link text: Python Official Link text - 1: Python Official Link text - 2: Hitchhiker’s Guide to Python Link text - 3: Dive Into Python Link text - 4: Real Python Link text - 5: Python Subreddit Link text - 6: Talk Python Podcast Link text - 7: Awesome Python Question text area placeholder: Your question... Navigation item - 1: About Navigation item - 2: BOPI Navigation item - 3: Feedback Support button text: Support Me There is no h1 tag in the document! 3# OutputMail input field placeholder: [email protected] Submit button text: SUBMIT QUESTION Second link text: Hitchhiker’s Guide to Python Python Official link text: Python Official Link text - 1: Python Official Link text - 2: Hitchhiker’s Guide to Python Link text - 3: Dive Into Python Link text - 4: Real Python Link text - 5: Python Subreddit Link text - 6: Talk Python Podcast Link text - 7: Awesome Python Question text area placeholder: Your question... Navigation item - 1: About Navigation item - 2: BOPI Navigation item - 3: Feedback Support button text: Support Me There is no h1 tag in the document! 4# OutputMail input field placeholder: [email protected] Submit button text: SUBMIT QUESTION Second link text: Hitchhiker’s Guide to Python Python Official link text: Python Official Link text - 1: Python Official Link text - 2: Hitchhiker’s Guide to Python Link text - 3: Dive Into Python Link text - 4: Real Python Link text - 5: Python Subreddit Link text - 6: Talk Python Podcast Link text - 7: Awesome Python Question text area placeholder: Your question... Navigation item - 1: About Navigation item - 2: BOPI Navigation item - 3: Feedback Support button text: Support Me There is no h1 tag in the document! 5# OutputMail input field placeholder: [email protected] Submit button text: SUBMIT QUESTION Second link text: Hitchhiker’s Guide to Python Python Official link text: Python Official Link text - 1: Python Official Link text - 2: Hitchhiker’s Guide to Python Link text - 3: Dive Into Python Link text - 4: Real Python Link text - 5: Python Subreddit Link text - 6: Talk Python Podcast Link text - 7: Awesome Python Question text area placeholder: Your question... Navigation item - 1: About Navigation item - 2: BOPI Navigation item - 3: Feedback Support button text: Support Me There is no h1 tag in the document! 6# OutputMail input field placeholder: [email protected] Submit button text: SUBMIT QUESTION Second link text: Hitchhiker’s Guide to Python Python Official link text: Python Official Link text - 1: Python Official Link text - 2: Hitchhiker’s Guide to Python Link text - 3: Dive Into Python Link text - 4: Real Python Link text - 5: Python Subreddit Link text - 6: Talk Python Podcast Link text - 7: Awesome Python Question text area placeholder: Your question... Navigation item - 1: About Navigation item - 2: BOPI Navigation item - 3: Feedback Support button text: Support Me There is no h1 tag in the document! 7# OutputMail input field placeholder: [email protected] Submit button text: SUBMIT QUESTION Second link text: Hitchhiker’s Guide to Python Python Official link text: Python Official Link text - 1: Python Official Link text - 2: Hitchhiker’s Guide to Python Link text - 3: Dive Into Python Link text - 4: Real Python Link text - 5: Python Subreddit Link text - 6: Talk Python Podcast Link text - 7: Awesome Python Question text area placeholder: Your question... Navigation item - 1: About Navigation item - 2: BOPI Navigation item - 3: Feedback Support button text: Support Me There is no h1 tag in the document! 8# OutputMail input field placeholder: [email protected] Submit button text: SUBMIT QUESTION Second link text: Hitchhiker’s Guide to Python Python Official link text: Python Official Link text - 1: Python Official Link text - 2: Hitchhiker’s Guide to Python Link text - 3: Dive Into Python Link text - 4: Real Python Link text - 5: Python Subreddit Link text - 6: Talk Python Podcast Link text - 7: Awesome Python Question text area placeholder: Your question... Navigation item - 1: About Navigation item - 2: BOPI Navigation item - 3: Feedback Support button text: Support Me There is no h1 tag in the document! 9
Các phương thức này trả về một tập hợp các phần tử. Nếu chỉ tìm thấy một phần tử, nó vẫn sẽ trả về một danh sách (của một phần tử). Nếu không tìm thấy phần tử nào, một danh sách trống sẽ được trả về Có hai phương thức khác mà bạn có thể sử dụng với sự trợ giúp của By class # OutputMail input field placeholder: [email protected] Submit button text: SUBMIT QUESTION Second link text: Hitchhiker’s Guide to Python Python Official link text: Python Official Link text - 1: Python Official Link text - 2: Hitchhiker’s Guide to Python Link text - 3: Dive Into Python Link text - 4: Real Python Link text - 5: Python Subreddit Link text - 6: Talk Python Podcast Link text - 7: Awesome Python Question text area placeholder: Your question... Navigation item - 1: About Navigation item - 2: BOPI Navigation item - 3: Feedback Support button text: Support Me There is no h1 tag in the document! 20# OutputMail input field placeholder: [email protected] Submit button text: SUBMIT QUESTION Second link text: Hitchhiker’s Guide to Python Python Official link text: Python Official Link text - 1: Python Official Link text - 2: Hitchhiker’s Guide to Python Link text - 3: Dive Into Python Link text - 4: Real Python Link text - 5: Python Subreddit Link text - 6: Talk Python Podcast Link text - 7: Awesome Python Question text area placeholder: Your question... Navigation item - 1: About Navigation item - 2: BOPI Navigation item - 3: Feedback Support button text: Support Me There is no h1 tag in the document! 21
Các thuộc tính có sẵn cho Theo lớp là # OutputMail input field placeholder: [email protected] Submit button text: SUBMIT QUESTION Second link text: Hitchhiker’s Guide to Python Python Official link text: Python Official Link text - 1: Python Official Link text - 2: Hitchhiker’s Guide to Python Link text - 3: Dive Into Python Link text - 4: Real Python Link text - 5: Python Subreddit Link text - 6: Talk Python Podcast Link text - 7: Awesome Python Question text area placeholder: Your question... Navigation item - 1: About Navigation item - 2: BOPI Navigation item - 3: Feedback Support button text: Support Me There is no h1 tag in the document! 22# OutputMail input field placeholder: [email protected] Submit button text: SUBMIT QUESTION Second link text: Hitchhiker’s Guide to Python Python Official link text: Python Official Link text - 1: Python Official Link text - 2: Hitchhiker’s Guide to Python Link text - 3: Dive Into Python Link text - 4: Real Python Link text - 5: Python Subreddit Link text - 6: Talk Python Podcast Link text - 7: Awesome Python Question text area placeholder: Your question... Navigation item - 1: About Navigation item - 2: BOPI Navigation item - 3: Feedback Support button text: Support Me There is no h1 tag in the document! 23# OutputMail input field placeholder: [email protected] Submit button text: SUBMIT QUESTION Second link text: Hitchhiker’s Guide to Python Python Official link text: Python Official Link text - 1: Python Official Link text - 2: Hitchhiker’s Guide to Python Link text - 3: Dive Into Python Link text - 4: Real Python Link text - 5: Python Subreddit Link text - 6: Talk Python Podcast Link text - 7: Awesome Python Question text area placeholder: Your question... Navigation item - 1: About Navigation item - 2: BOPI Navigation item - 3: Feedback Support button text: Support Me There is no h1 tag in the document! 24# OutputMail input field placeholder: [email protected] Submit button text: SUBMIT QUESTION Second link text: Hitchhiker’s Guide to Python Python Official link text: Python Official Link text - 1: Python Official Link text - 2: Hitchhiker’s Guide to Python Link text - 3: Dive Into Python Link text - 4: Real Python Link text - 5: Python Subreddit Link text - 6: Talk Python Podcast Link text - 7: Awesome Python Question text area placeholder: Your question... Navigation item - 1: About Navigation item - 2: BOPI Navigation item - 3: Feedback Support button text: Support Me There is no h1 tag in the document! 25# OutputMail input field placeholder: [email protected] Submit button text: SUBMIT QUESTION Second link text: Hitchhiker’s Guide to Python Python Official link text: Python Official Link text - 1: Python Official Link text - 2: Hitchhiker’s Guide to Python Link text - 3: Dive Into Python Link text - 4: Real Python Link text - 5: Python Subreddit Link text - 6: Talk Python Podcast Link text - 7: Awesome Python Question text area placeholder: Your question... Navigation item - 1: About Navigation item - 2: BOPI Navigation item - 3: Feedback Support button text: Support Me There is no h1 tag in the document! 26# OutputMail input field placeholder: [email protected] Submit button text: SUBMIT QUESTION Second link text: Hitchhiker’s Guide to Python Python Official link text: Python Official Link text - 1: Python Official Link text - 2: Hitchhiker’s Guide to Python Link text - 3: Dive Into Python Link text - 4: Real Python Link text - 5: Python Subreddit Link text - 6: Talk Python Podcast Link text - 7: Awesome Python Question text area placeholder: Your question... Navigation item - 1: About Navigation item - 2: BOPI Navigation item - 3: Feedback Support button text: Support Me There is no h1 tag in the document! 27# OutputMail input field placeholder: [email protected] Submit button text: SUBMIT QUESTION Second link text: Hitchhiker’s Guide to Python Python Official link text: Python Official Link text - 1: Python Official Link text - 2: Hitchhiker’s Guide to Python Link text - 3: Dive Into Python Link text - 4: Real Python Link text - 5: Python Subreddit Link text - 6: Talk Python Podcast Link text - 7: Awesome Python Question text area placeholder: Your question... Navigation item - 1: About Navigation item - 2: BOPI Navigation item - 3: Feedback Support button text: Support Me There is no h1 tag in the document! 28# OutputMail input field placeholder: [email protected] Submit button text: SUBMIT QUESTION Second link text: Hitchhiker’s Guide to Python Python Official link text: Python Official Link text - 1: Python Official Link text - 2: Hitchhiker’s Guide to Python Link text - 3: Dive Into Python Link text - 4: Real Python Link text - 5: Python Subreddit Link text - 6: Talk Python Podcast Link text - 7: Awesome Python Question text area placeholder: Your question... Navigation item - 1: About Navigation item - 2: BOPI Navigation item - 3: Feedback Support button text: Support Me There is no h1 tag in the document! 29
Chúng được sử dụng như trong đoạn mã dưới đây # OutputMail input field placeholder: [email protected] Submit button text: SUBMIT QUESTION Second link text: Hitchhiker’s Guide to Python Python Official link text: Python Official Link text - 1: Python Official Link text - 2: Hitchhiker’s Guide to Python Link text - 3: Dive Into Python Link text - 4: Real Python Link text - 5: Python Subreddit Link text - 6: Talk Python Podcast Link text - 7: Awesome Python Question text area placeholder: Your question... Navigation item - 1: About Navigation item - 2: BOPI Navigation item - 3: Feedback Support button text: Support Me There is no h1 tag in the document! 0Tất cả các phương thức # OutputMail input field placeholder: [email protected] Submit button text: SUBMIT QUESTION Second link text: Hitchhiker’s Guide to Python Python Official link text: Python Official Link text - 1: Python Official Link text - 2: Hitchhiker’s Guide to Python Link text - 3: Dive Into Python Link text - 4: Real Python Link text - 5: Python Subreddit Link text - 6: Talk Python Podcast Link text - 7: Awesome Python Question text area placeholder: Your question... Navigation item - 1: About Navigation item - 2: BOPI Navigation item - 3: Feedback Support button text: Support Me There is no h1 tag in the document! 30 có thể được gọi trên cả hai phiên bản # OutputMail input field placeholder: [email protected] Submit button text: SUBMIT QUESTION Second link text: Hitchhiker’s Guide to Python Python Official link text: Python Official Link text - 1: Python Official Link text - 2: Hitchhiker’s Guide to Python Link text - 3: Dive Into Python Link text - 4: Real Python Link text - 5: Python Subreddit Link text - 6: Talk Python Podcast Link text - 7: Awesome Python Question text area placeholder: Your question... Navigation item - 1: About Navigation item - 2: BOPI Navigation item - 3: Feedback Support button text: Support Me There is no h1 tag in the document! 31 và # OutputMail input field placeholder: [email protected] Submit button text: SUBMIT QUESTION Second link text: Hitchhiker’s Guide to Python Python Official link text: Python Official Link text - 1: Python Official Link text - 2: Hitchhiker’s Guide to Python Link text - 3: Dive Into Python Link text - 4: Real Python Link text - 5: Python Subreddit Link text - 6: Talk Python Podcast Link text - 7: Awesome Python Question text area placeholder: Your question... Navigation item - 1: About Navigation item - 2: BOPI Navigation item - 3: Feedback Support button text: Support Me There is no h1 tag in the document! 0, điều đó có nghĩa là nếu bạn xác định vị trí phần tử vùng chứa bằng cách gọi phương thức # OutputMail input field placeholder: [email protected] Submit button text: SUBMIT QUESTION Second link text: Hitchhiker’s Guide to Python Python Official link text: Python Official Link text - 1: Python Official Link text - 2: Hitchhiker’s Guide to Python Link text - 3: Dive Into Python Link text - 4: Real Python Link text - 5: Python Subreddit Link text - 6: Talk Python Podcast Link text - 7: Awesome Python Question text area placeholder: Your question... Navigation item - 1: About Navigation item - 2: BOPI Navigation item - 3: Feedback Support button text: Support Me There is no h1 tag in the document! 30 trên phiên bản # OutputMail input field placeholder: [email protected] Submit button text: SUBMIT QUESTION Second link text: Hitchhiker’s Guide to Python Python Official link text: Python Official Link text - 1: Python Official Link text - 2: Hitchhiker’s Guide to Python Link text - 3: Dive Into Python Link text - 4: Real Python Link text - 5: Python Subreddit Link text - 6: Talk Python Podcast Link text - 7: Awesome Python Question text area placeholder: Your question... Navigation item - 1: About Navigation item - 2: BOPI Navigation item - 3: Feedback Support button text: Support Me There is no h1 tag in the document! 31, bạn có thể gọi # OutputMail input field placeholder: [email protected] Submit button text: SUBMIT QUESTION Second link text: Hitchhiker’s Guide to Python Python Official link text: Python Official Link text - 1: Python Official Link text - 2: Hitchhiker’s Guide to Python Link text - 3: Dive Into Python Link text - 4: Real Python Link text - 5: Python Subreddit Link text - 6: Talk Python Podcast Link text - 7: Awesome Python Question text area placeholder: Your question... Navigation item - 1: About Navigation item - 2: BOPI Navigation item - 3: Feedback Support button text: Support Me There is no h1 tag in the document! 30 trên phần tử này để tìm kiếm thêm các phần tử bên trong nó
Làm cách nào để tìm các phần tử bằng CSS Selector?
Nhập “css=input[type='submit']” (giá trị định vị) trong Selenium IDE. Bấm vào nút Tìm. Nút “Đăng nhập” sẽ được tô sáng, xác minh giá trị của bộ định vị. Thuộc tính. Được sử dụng để tạo Bộ chọn CSS
Bộ chọn CSS Selenium là gì?
Bộ chọn CSS trong Selenium là gì? . Bộ chọn CSS chủ yếu sử dụng mẫu chuỗi ký tự, xác định các phần tử web dựa trên cấu trúc HTML của chúng
Bộ chọn CSS trong Python Selenium là gì?
Bộ chọn CSS là sự kết hợp của bộ chọn phần tử và giá trị xác định phần tử web trong trang web . Chúng là các biểu diễn chuỗi của thẻ HTML, thuộc tính, Id và Class.
Làm cách nào để sử dụng Find_element trong Selenium Python?
|