Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/345.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过xpath、Python、tinder发布选择按钮_Python_Selenium_Xpath_Css Selectors_Tinder - Fatal编程技术网

通过xpath、Python、tinder发布选择按钮

通过xpath、Python、tinder发布选择按钮,python,selenium,xpath,css-selectors,tinder,Python,Selenium,Xpath,Css Selectors,Tinder,我很难选择像火绒一样的按钮。我刚刚从tinder的web版本复制了Xpath。它适用于“不喜欢”按钮,而不适用于“喜欢”按钮。我还尝试添加一个睡眠按钮,以防like按钮渲染不够快 def dislike(self): dislike_btn = self.driver.find_element_by_xpath('//*[@id="content"]/div/div[1]/div/main/div[1]/div/div/div[1]/div/div[2]/button[1]')

我很难选择像火绒一样的按钮。我刚刚从tinder的web版本复制了Xpath。它适用于“不喜欢”按钮,而不适用于“喜欢”按钮。我还尝试添加一个睡眠按钮,以防like按钮渲染不够快

def dislike(self):
    dislike_btn = self.driver.find_element_by_xpath('//*[@id="content"]/div/div[1]/div/main/div[1]/div/div/div[1]/div/div[2]/button[1]')
    dislike_btn.click()

def like(self):
    like_btn = self.driver.find_element_by_xpath('//*[@id="content"]/div/div[1]/div/div/main/div/div[1]/div/div[2]/button[3]')
    like_btn.click()
我曾尝试通过CSS选择器进行选择,但也不起作用


我是一个绝对的noob,所以如果我错过了一些相关的信息,请发发慈悲:D

尝试直接单击元素而不指定它。这对我来说是有效的,并且检查like按钮上是否有任何重叠的元素

driver.find_element_by_xpath('//*[@id="content"]/div/div[1]/div/main/div[1]/div/div/div[1]/div/div[2]/button[3]').click()

如果在browser developer控制台中执行CTRL+F并粘贴未识别的xpath,它是否会找到/突出显示它?另外,请添加相关的html源代码。