標準功能
需求靈活選用。 這些工具所涵蓋的各項瀏覽器自動化能力,在我們的 瀏覽器API 中已獲得完整支援。這意味著,在使用過程中,你可以直接查閱對應技術的官方文件,所有功能均可無縫適配、順利調用,獲取可靠的技術支援將更加輕鬆便捷。
技術堆疊
const page = await page.newPage();
await page.goto('https://example.com'); await page.screenshot({ path: 'screenshot.png', fullPage: true });const page = await browser.newPage();
await page.goto('https://example.com');
const html = await page.content();// Wait and click on first result.
await page.locator('.devsite-result-item-link').click()
# Start the session
driver = webdriver.Chrome()
# Take action on browser
driver.get("https://www.selenium.dev/selenium/web/web-form.html")
# Request browser information
title = driver.title
driver.implicitly_wait(0.5)
#Find an element
text_box = driver.find_element(by=By.NAME, value="my-text")
submit_button = driver.find_element(by=By.CSS_SELECTOR, value="button")
# Take action on element
text_box.send_keys("Selenium")
submit_button.click()
# Request element information
message = driver.find_element(by=By.ID, value="message")
text = message.text
# End the session
driver.quit() // Start the Browser
driver = await new Builder().forBrowser(Browser.CHROME).build();
// GOTO UTL on browser
await driver.get('https://www.selenium.dev/selenium/web/web-form.html');
// Request browser information
let title = await driver.getTitle();
// Waiting
await driver.manage().setTimeouts({implicit: 500});
// Find an element
let textBox = await driver.findElement(By.name('my-text'));
let submitButton = await driver.findElement(By.css('button'));
// Take action on element
await textBox.sendKeys('Selenium');
await submitButton.click();
// Request element information
let message = await driver.findElement(By.id('message'));
let value = await message.getText();
// End the session
await driver.quit();运行
請儲存以下程式碼(別忘記輸入您的憑證!),並使用以下指令執行它:script.js
# Start the session
driver = webdriver.Chrome()
# Take action on browser
driver.get("https://www.selenium.dev/selenium/web/web-form.html")
# Request browser information
title = driver.title
driver.implicitly_wait(0.5)
#Find an element
text_box = driver.find_element(by=By.NAME, value="my-text")
submit_button = driver.find_element(by=By.CSS_SELECTOR, value="button")
# Take action on element
text_box.send_keys("Selenium")
submit_button.click()
# Request element information
message = driver.find_element(by=By.ID, value="message")
text = message.text
# End the session
driver.quit()
// Start the Browser
driver = await new Builder().forBrowser(Browser.CHROME).build();
// GOTO UTL on browser
await driver.get('https://www.selenium.dev/selenium/web/web-form.html');
// Request browser information
let title = await driver.getTitle();
// Waiting
await driver.manage().setTimeouts({implicit: 500});
// Find an element
let textBox = await driver.findElement(By.name('my-text'));
let submitButton = await driver.findElement(By.css('button'));
// Take action on element
await textBox.sendKeys('Selenium');
await submitButton.click();
// Request element information
let message = await driver.findElement(By.id('message'));
let value = await message.getText();
// End the session
await driver.quit();如果您需要进一步说明方面的帮助,请随时通过以下方式与我们联系: [email protected].
Last updated
Was this helpful?