他用Python和Selenium编写了一个程序。在网站上,我有一个按钮:
<button class="_rfh _4jy0 _4jy4 _517h _51sy _42ft" type="submit" value="1"><i alt="" class="_3-8_ img sp_DV9drRVqFBy sx_08f171"></i>Udostępnij</button>
我在我的程序中写下,他会按下这个按钮:
driver.find_element_by_xpath('//*[@class="_4jy0 _4jy4 _517h _51sy _42ft"]').click()
但程序不会单击此按钮,而是单击此页面上的另一个按钮,如下所示:
<button class="likeButton _4jy0 _4jy4 _517h _51sy _42ft" data-testid="page_profile_like_button_test_id" type="submit" value="1"><i alt="" class="_3-8_ img sp_DV9drRVqFBy sx_e53c72"></i>Lubię to!</button>
有人知道为什么会这样吗
它不会粘贴所有代码,因为它太长了。发生错误的地方是:
请检查类是否是动态的,同时检查下面的xpath是否适合您
或
注意:请添加以下导入内容
相关问题 更多 >
编程相关推荐