Skip to content

Commit ba0ad54

Browse files
update examples
1 parent 01095cc commit ba0ad54

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

README.md

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,20 +71,31 @@ local server = webdriver.newLocalServer({
7171
port = 4444
7272
})
7373

74-
-- Create browser session
74+
-- Create a new browser session
7575
local session = server.newSession({
76-
binary_location = "./chrome/chrome-linux64/chrome"
76+
binary_location = "./chrome/chrome-linux64/chrome",
7777
})
7878

79-
-- Navigate and interact
80-
session.navegate_to("https://google.com")
81-
local searchBox = session.get_element("css selector", "input[name='q']")
82-
searchBox.send_keys("Lua programming")
79+
-- Navigate to a website
80+
session.navegate_to("https://news.ycombinator.com")
8381

84-
local searchButton = session.get_element("css selector", "input[type='submit']")
85-
searchButton.click()
82+
-- Find and interact with elements
83+
local big_box = session.get_element_by_id("bigbox")
84+
local td = big_box[1]
85+
local table_1 = td[1]
86+
local tbody = table_1[1]
87+
88+
-- Print all news items
89+
print("=== Hacker News Articles ===")
90+
for i = 1, tbody.get_children_size() do
91+
local tr = tbody.get_element_by_index(i)
92+
local text = tr.get_text()
93+
if text and text ~= "" then
94+
print(i .. ". " .. text)
95+
end
96+
end
8697

87-
print("Search completed! 🎉")
98+
print("✅ Test completed successfully!")
8899
```
89100

90101
### 3. Run Your Script

0 commit comments

Comments
 (0)