如何在联系人列表中向下滚动,直到我在python中使用硒找到了目标用户

我正在自动执行我的whatsapp发送消息,我要发送,但是如果该联系人不可见(如果它在我的联系人列表的底部),则硒找不到用户。所以我想做类似的事情,如果用户找不到,则向下滚动直到找到用户。

我尝试使用send_Keys(KEY.PAGE_DOWN)函数,但随后无法正常工作,它只能向下滚动一点,直到我希望滚动到该特定用户为止。

try:
        name = ["wenxuan","凯文","lzs real","GG Exhibition(DEM & DIT)","seaboom"]

        for names in name:  # loop across the list of user name
            user = driver.find_element_by_xpath('//span[@title = "{}"]'.format(names))  # locate the user
            user.click()  # click in to that user
except:
        #exception occur when the user is not visible
        print("User not found im scrolling down")
        groupName = driver.find_elements_by_css_selector("span._19RFN._1ovWX")
        gName = [message.text for message in groupName]  # get the user name
        print(gName[-1])
        if gName[-1] == "GG": # if the name of the user is GG mean the bottom of contact list
            for z in range(99):
                driver.find_element_by_tag_name('body').send_keys(
                    Keys.PAGE_UP) # scroll up

        else:

            driver.find_element_by_tag_name('body').send_keys(
                        Keys.PAGE_DOWN) # if user not found scroll down

我想要的输出是我可以滚动到该特定用户,然后在找不到该用户的情况下单击

qqmcgs2009 回答:如何在联系人列表中向下滚动,直到我在python中使用硒找到了目标用户

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3123421.html

大家都在问