20210707web 作业

本贴最后更新于 1229 天前,其中的信息可能已经水流花落
24 回帖
请输入回帖内容 ...
  • H

    public ChromeDriver() {

    this(ChromeDriverService.createDefaultService(), new ChromeOptions());
    }

    public static final String CHROME_DRIVER_EXE_PROPERTY = "webdriver.chrome.driver";

    public static void main( String[] args )

    {

    System.setProperty("webdriver.chrome.driver","D:\test\driver\chromeDriver.exe");

    WebDriver driver = new ChromeDriver();

    driver.get("http://testingpai.com/");
    }
    driver.find_element_by_css_selector("fn__layer fn__layer--big").click()

  • 其他回帖
  • mary369

    #coding:utf-8

    from selenium import webdriver
    from time import sleep

    #初始化
    browser = webdriver.Chrome()
    browser.maximize_window()
    browser.get('https://www.fliggy.com/')
    browser.implicitly_wait(10)

    #输入出发城市
    depCity = browser.find_element_by_xpath('//input[@name="depCityName"]')
    depCity.clear()
    depCity.send_keys(u'昆明')
    sleep(1)
    #输入到达城市
    arrCity = browser.find_element_by_xpath('//input[@name="arrCityName"]')
    arrCity.clear()
    arrCity.send_keys(u'长沙')
    sleep(1)
    #输入出发日期
    depDate = browser.find_element_by_xpath('//input[@name="depDate"]')
    depDate.send_keys('2021-07-10')
    #关闭日期控件
    browser.find_element_by_xpath('//span[text()="close"]').click()
    sleep(2)
    #点击搜索按钮
    browser.find_element_by_xpath('//form[@id="J_FlightForm"]//button[text()="搜索"]').click()
    sleep(5)

    #退出
    browser.quit()

    1 回复
  • H

    public static void textControl(WebDriver driver, String name,String txt){ WebElement element = driver.findElement(By.name(name)); element.clear(); element.sendKeys(txt); } public static void loginFeizhu() throws InterruptedException { WebDriver driver = init(); driver.get("https://www.fliggy.com/"); Thread.sleep(1000); driver.findElement(By.xpath("//input[@placeholder="目的地/酒店/景点/签证等"]")).click(); Thread.sleep(1000); driver.findElement(By.xpath("//div[@class="recommend-values"]/span[contains(text(),"机票")and @data-itemindex=0]")).click(); */ textControl(driver,"depCityName", "上海")); textControl(driver,"arrCityName","长沙"); textControl(driver,"depDate","2021-07-10"); driver.findElement(By.cssSelector(".close-btn.delegate-click-381")).click(); Thread.sleep(3000); driver.findElement(By.xpath("//form[@id="J_FlightForm"]//button[text()="搜索"]")).click(); tearDown(driver); }

    1 回复
  • scb21sunny

    QQ截图20210709150132.png
    QQ截图20210709150149.png
    QQ截图20210709150142.png
    QQ截图20210709150204.png
    QQ截图20210709150157.png

    1 回复
  • 查看更多回帖