0
driver = webdriver.PhantomJS()
driver.set_window_size(1920, 1080)
driver.get('https://soundcloud.com/')
driver.implicitly_wait(5)
driver.set_page_load_timeout(5)
#driver.save_screenshot('screen.png')
signIn_button = driver.find_element_by_xpath("//button[@class='g-opacity-transition frontHero__loginButton g-button-transparent-inverted sc-button sc-button-medium loginButton']")
signIn_button.click()
driver.implicitly_wait(5)
#driver.save_screenshot('screenie.png')
#emailField = driver.find_element_by_css_selector('form#loginForm input[placeholder="Your email address or profile URL *"]')Your email address or profile URL *
emailField = driver.find_element_by_xpath("//input[@class='textfield__input sc-input sc-input-large'][@type='text']")
emailField.click()
driver.implicitly_wait(5)
emailField.send_keys(account.email)
driver.implicitly_wait(5)
emailField.send_keys(Keys.RETURN)
當線driver.save_screenshot('screenie.png')
是在代碼,該程序的功能正常,正確地在emailField
與正確的串入。但是,如果刪除了此代碼,程序將無法操作此文本字段並引發錯誤:拿走硒截圖功能使得程序失敗 - 的Python
selenium.common.exceptions.ElementNotVisibleException: Message: {"errorMessage":"Element is not currently visible and may not be manipulated"