Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How toextract the number from the parent div excluding the text of the child using Selenium IDE

I’m trying to fetch the number out the Steam site -> https://store.steampowered.com/about/

Element snapshot:

Steam online users

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Code trials:

await driver.findElement(By.xpath("//div[@class='online_stats']//div[2][@class='online_stat']")).getText().then((text)=>{
  onlinePlayersInGames = text;
});

Doing it with this code results in me getting a returned value of:

ONLINE
22,099,967

Rather than only fetching the number.

>Solution :

To extract the data for playing now:

await driver.findElement(By.xpath("//div[@class='online_stat'][./div[@class='online_stat_label gamers_in_game']]")).getText().then((text)=>{
  onlinePlayersInGames = text;
});

To extract the data for online:

await driver.findElement(By.xpath("//div[@class='online_stat'][./div[@class='online_stat_label gamers_online']]")).getText().then((text)=>{
  onlinePlayersInGames = text;
});
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading