How to find_element_by_link_text while having: NoSuchElement Exception?

前端 未结 4 1122
独厮守ぢ
独厮守ぢ 2021-01-14 22:31

This question has been asked over and over again - and in-spite of trying all the hacks I still can\'t seem to figure out what\'s wrong.

I tried increasing t

4条回答
  •  攒了一身酷
    2021-01-14 23:03

    Solution posted by OP:

    Hack 1: Instead of identifying the element as a text-link, I identified the "bigger frame" in which this element was present. itemlist_1 = driver.find_element_by_css_selector("li.item.first").text This will give the whole item along with the name, price and detail (and the unwanted add to cart and compare"

    See the attached image for more . enter image description here

    Hack 2: I found that the "Buy Now" which was an image element with xPath (driver.find_element_by_xpath("//div[@id='subseries']/div[2]/div/p[3]/a").click() , in the code above) , could be made to click/identified faster if I added the following line, before finding this by xpath. I think this sort of narrows down where the Webdriver is looking for an element. This is what I added " driver.find_element_by_css_selector("#subseries").text"

    This must have decreased my wait by at least 20 seconds, on that page .Hope that helps.

提交回复
热议问题