Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Selenium locating an element.
#1
Hi guys !
So I have an question about Selenium, I want to locate the userName tag . By inspecting the site I found this whole class :
" <span class="b-link js-profile-header-name js-hp-view-element" data-element-name="userName"></span> " .

Thats pretty much it but it is in "profile-header__user" class and thats in profile-header__info and that is in profile-header__inner and so on ....There are many div classes and I guess thats the issue.
My code cant find the button ( which isnt a button but when you hover on it you can click on it) ,and I want Selenium to click on it. Ive try multiple combination.

Can`t search for text because always when the site refreshes ,the name will change.
Can you guys give me a hint or maybe an article to read or something .
Im still learning so please dont get upset :) !

Have a nice day !
JokerTux.
Reply
#2
Can you post link to site?,it's hard to test this stuff without doing it live.

I have setup so i can do some testing local.
The span tag usually get some date,here i put in username.
<span class="b-link js-profile-header-name js-hp-view-element" data-element-name="userName">username</span>
in my test code.
span = browser.find_elements_by_class_name('b-link')
E:\div_code\scrape
λ ptpython -i local_chrome.py

>>> span
[<selenium.webdriver.remote.webelement.WebElement (session="f09352246e80ff04e3ce05999703987c", element="e479c4a5-40e0-4636-915d-ff1ea297ac8f")>]

>>> span[0].text
'username'
This may not work on the web-site,there are lot of different setup eg a lot diffent JS framework and technique used.
The web code is really mess under the hood Doh
Reply
#3
Hi !
Thank you for your quick replay , so the site is badoo.com :D .
I was writing a script that looks into the personal details and checks if this person has kids for example.
After getting this information the next step is to reject or click on the love button ,but I`m not that far yet.
The main issue is it wont click on the name which after clicking on it gives more details.
Its not that important , its just a project for fun ;).
Reply
#4
(Dec-27-2019, 05:25 PM)JokerTux Wrote: Thank you for your quick replay , so the site is badoo.com :D .
I am not gone register to a dating site to test this out Wink
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Selenium suddenly fails to find element Pavel_47 3 6,197 Sep-04-2022, 11:06 AM
Last Post: Pavel_47
  Locating elements via Selenium peterjv26 2 2,432 Oct-02-2020, 07:50 AM
Last Post: peterjv26
  Clicking on element not triggering event in Selenium Python (Event Key is not in data dkaeloredo 2 4,230 Feb-16-2020, 05:50 AM
Last Post: dkaeloredo
  Selenium returning web element instead of desired text newbie_programmer 1 5,142 Dec-11-2019, 06:37 AM
Last Post: Malt
  Python Selenium getting table element trengan 2 8,504 Dec-31-2018, 03:02 PM
Last Post: trengan
  Click Element if displayed using Selenium and Python giaco__mar 1 3,485 Dec-27-2018, 06:19 PM
Last Post: metulburr
  Selenium stale element reference test 1 2,737 Sep-19-2018, 10:19 PM
Last Post: test
  Simple Element Check Code in Selenium Not Working digitalmatic7 1 2,978 Feb-18-2018, 06:53 AM
Last Post: metulburr
  Selenium - Googlemaps element not visible Barnettch3 3 5,570 Jan-15-2018, 08:07 PM
Last Post: Barnettch3
  locating element with selenium after login sumandas89 1 3,605 Jan-15-2018, 02:40 PM
Last Post: metulburr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020