I'm trying to click on like button. I have tried "find_element_by_xpath()" but it didn't worked for me. Little confused how to do so
Here is the Inspects Complete Class Code:
<div class="grid">
<div class="user_hover_panel" style="width:100%;">
<ul class="list--horizontal float--left post-icons-list ng-isolate-scope" wt-on-outside-click="$ctrl.emojiOutSideClick($ctrl.postData.id)" wt-on-outside-click-enabled="$ctrl.toggleEmoji">
<li ng-class="{'selected': $ctrl.postData.is_liked, 'liked-desk' : true ,
'like-border-right' : ($ctrl.postData.privacyType == 'Personal' || $ctrl.postData.privacyType == 'Pro' || $ctrl.postData.privacyType == 'All' || $ctrl.postData.privacyType == 'Public'),
'like-border-none' : ($ctrl.postData.privacyType == 'Groups' || $ctrl.postData.privacyType == 'Staff' || $ctrl.postData.privacyType == 'Private')}" class="liked-desk like-border-right">
<a ng-mouseover="$ctrl.userContext.id != undefined && !$ctrl.isMobile && $ctrl.showLikeEmoji($ctrl.postData.id)" ng-mouseleave="$ctrl.hideLikeEmoji()" ng-click="!$ctrl.isMobile ? $ctrl.likeMedia($ctrl.postData.id, $root.context.id, $ctrl.postData.mediaTypeTagging, $ctrl.postData, true):$ctrl.toggleReaction($ctrl.postData.id)" class="cursor--pointer " data-own-entry="false">
<!-- ngIf: !$ctrl.postData.is_liked -->
<i ng-if="!$ctrl.postData.is_liked" class="icon icon-post-like private-link ng-scope">Like</i>
<!-- end ngIf: !$ctrl.postData.is_liked -->
<!-- ngIf: $ctrl.postData.is_liked -->
</a>
</li>
<li class="comment-desk" ng-click="$ctrl.togglePostCommentBox()">
<a href="javascript:" data-own-entry="false">
<i class="icon icon-post-cmt private-link">Comment</i>
</a>
</li>
<!-- ngIf: !$ctrl.isModalView && !$ctrl.isPostAsComment --><li ng-if="!$ctrl.isModalView && !$ctrl.isPostAsComment" ng-class="{
'shared-desk' : true}" ng-hide="$ctrl.postData.privacyType != 'Public'" class="ng-scope shared-desk">
<!-- ngIf: $ctrl.postData.mediaTypeTagging != 'photos' && $ctrl.checkBannerOrProfile(false) --><a data-ng-if="$ctrl.postData.mediaTypeTagging != 'photos' && $ctrl.checkBannerOrProfile(false)" href="javascript:" ng-click="$ctrl.shareMedia('news', $ctrl.postData.post_share_id ? $ctrl.postData.post_share_id : $ctrl.postData.post_id, $ctrl.postData.privacyType)" class="" data-own-entry="false">
<i class="icon icon-post-share private-link">Share</i>
</a><!-- end ngIf: $ctrl.postData.mediaTypeTagging != 'photos' && $ctrl.checkBannerOrProfile(false) -->
<!-- ngIf: $ctrl.postData.mediaTypeTagging !='news' && $ctrl.postData.mediaTypeTagging == 'photos' && $ctrl.postData.id != undefined && $ctrl.checkBannerOrProfile(false) -->
</li><!-- end ngIf: !$ctrl.isModalView && !$ctrl.isPostAsComment -->
</ul>
<!-- ngIf: $ctrl.userContext.id != undefined && $ctrl.toggleEmoji && $ctrl.postEmojiId == $ctrl.postData.id -->
</div>
</div>
I want to Click on :
<!-- ngIf: !$ctrl.postData.is_liked -->
<i ng-if="!$ctrl.postData.is_liked" class="icon icon-post-like private-link ng-scope">Like</i><!-- end ngIf: !$ctrl.postData.is_liked -->
<!-- ngIf: $ctrl.postData.is_liked -->
Also I'm not sure if I'm clicking on right element! I just want to click on like button. I'm new with python and selenium and do not know how to do this.
Here is my code what I'm doing !
from selenium import webdriver
import pyautogui as py
import time
PATH = "C:\Program Files (x86)\chromedriver_win32\chromedriver.exe"
driver = webdriver.Chrome(PATH)
driver.get("https://www.webtalk.co/")
time.sleep(3)
driver.maximize_window()
like_button = driver.find_element_by_xpath("//*[@id="30247788"]/div[5]/div/div/ul/li[1]/a/i")
like_button.click()
I got this error !
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id='30247788']/div[5]/div/div/ul/li[1]/a/i"}
(Session info: chrome=90.0.4430.212)