硒python找不到元素

时间:2018-11-24 18:53:27

标签: python html python-3.x selenium selenium-webdriver

我尝试找到带有“检查器”镶边的元素。 我想要的元素查找元素的名称类似于“写消息”。用代码注释这是我尝试找到的元素

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time,random

driver = webdriver.Chrome()

links = 'https://eu1.badoo.com/profile/0655060811'


driver.get('https://badoo.com/signin/?f=top')
time.sleep(10)


element = driver.find_element_by_name('email')#.click()


element.send_keys('email@gmail.com')

element = driver.find_element_by_name('password')



element.send_keys("$#xxxx", Keys.ENTER)

time.sleep(15)

driver.get(links)

#element = driver.find_element_by_css_selector('#text-field > input[type="text"]').send_keys("hejka")


#element = driver.find_element_by_class_name('fast-message__content')#.send_keys("Hej", Keys.ENTER)
element = driver.find_element_by_xpath("(.//*[normalize-space(text()) and normalize-space(.)='Czatuj'])[1]/following::input[1]").click()


#element = driver.find_element_by_css_selector('div.fast-message__content')
#element = driver.find_element_by_xpath("//div[input/@type='text']").send_keys("hejka")
#element = driver.find_element_by_xpath("//input[@type='text']/input[0]").send_keys("hejka")
#element = driver.find_element_by_xpath("//input[@class='text-field__input']").send_keys("hejka")


#driver.find_element_by_css_selector('div.text-field__input')#.send_keys("hejka")
#driver.find_element_by_xpath("//*[@class='text-field']/input[@type='text']").send_keys("hejka")#'Hej', Keys.ENTER
#driver.find_element_by_class_name('fast-message__field-wrapper').send_keys("Hej", Keys.ENTER)

time.sleep(5)

我的错误:

  

回溯(最近通话最近):文件   “ D:\ 1 \ badoo \ vremm_dla_prob2.py”,第33行,在       元素= driver.find_element_by_xpath(“(.// [normalize-space(text())和   normalize-space(。)='Czatuj'])[1] / following :: input [1]“)。click()文件   “ C:\ Users \ Sylwia.thonny \ BundledPython36 \ lib \ site-packages \ selenium \ webdriver \ remote \ webdriver.py”,   第394行,在find_element_by_xpath中       返回self.find_element(by = By.XPATH,值= xpath)文件“ C:\ Users \ Sylwia.thonny \ BundledPython36 \ lib \ site-packages \ selenium \ webdriver \ remote \ webdriver.py”,   第978行,在find_element中       '值':值})['值']文件“ C:\ Users \ Sylwia.thonny \ BundledPython36 \ lib \ site-packages \ selenium \ webdriver \ remote \ webdriver.py”,   第321行,在执行中       self.error_handler.check_response(响应)文件“ C:\ Users \ Sylwia.thonny \ BundledPython36 \ lib \ site-packages \ selenium \ webdriver \ remote \ errorhandler.py”,   第242行,在check_response中       引发exception_class(message,screen,stacktrace)selenium.common.exceptions.NoSuchElementException:消息:没有这样   元素:无法找到元素:   {“ method”:“ xpath”,“ selector”:“(..// [normalize-space(text())and   normalize-space(。)='Czatuj'])[1] / following :: input [1]“}(会话   信息:chrome = 70.0.3538.102)(驱动程序信息:chromedriver = 2.43.600210   (xxxx),platform = Windows NT   6.1.7601 SP1 x86)

0 个答案:

没有答案