Basic Information
I have this software that I am developing for my personal use because im using it as a way to learn Selenium (By trial and error and so far I know the basics because I already went through it)
What the software does
It will analyze the top 5 most active stocks from a list on the website and print it out on to the software (Pretty simple right?)
The Issue
At this moment I've made it so it pulls a name & the percentage of top item from the list on this website (which used to be the top one) but then it changed to the 3rd one and what it does when I actually press the button is (as I just explained) it pulls the third option which is the one that used to be the first one
What I WOULD like it to do
I would need the correct TagName or the CssSelector which shows whats in the list from 1-5 EVEN if it changes, I would like it to change when the website changes
Example
I press the button (label11_Click) (Sorry for the bad naming on my part)
It shows the top 5 items
I close the app and wait 24 hours
The list changes on the website
I reopen the application after 24 hours
I press the same button (label11_Click)
it shows the new top 5 items
My Work At the moment
Website:
TradingView: Free Stock Charts and Forex Charts Online.[
^]
List:
This List Is Being Showed On The Website[
^]
The Inspector[
^]
My Code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.PhantomJS;
namespace TestingUI
{
public partial class mainForm : Form
{
Timer t = new Timer();
public mainForm()
{
InitializeComponent();
}
int mouseX = 0, mouseY = 0;
bool mouseDown;
private void viewDash(object sender, MouseEventArgs e)
{
}
private void panel1_MouseDown(object sender, MouseEventArgs e)
{
mouseDown = true;
}
private void panel1_MouseMove(object sender, MouseEventArgs e)
{
if (mouseDown)
{
mouseX = MousePosition.X - 200;
mouseY = MousePosition.Y - 40;
this.SetDesktopLocation(mouseX, mouseY);
}
}
private void panel1_MouseUp(object sender, MouseEventArgs e)
{
mouseDown = false;
}
private void leftsidePanel_Paint(object sender, PaintEventArgs e)
{
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
t.Interval = 1000;
t.Tick += new EventHandler(this.t_Tick);
t.Start();
}
private void t_Tick(object sender, EventArgs e)
{
int hh = DateTime.Now.Hour;
int mm = DateTime.Now.Minute;
int ss = DateTime.Now.Second;
string time = "";
if (hh < 10)
{
time += "0" + hh;
}
else
{
time += hh;
}
time += ":";
if (mm < 10)
{
time += "0" + mm;
}
else
{
time += mm;
}
time += ":";
if (ss < 10)
{
time += "0" + ss;
}
else
{
time += ss;
}
timeLabel.Text = time;
}
private void closeLabel_Click(object sender, EventArgs e)
{
this.Close();
}
private void topPanel_Paint(object sender, PaintEventArgs e)
{
}
private void dashPanel_MouseEnter_1(object sender, EventArgs e)
{
dashPanel.BackColor = System.Drawing.ColorTranslator.FromHtml("#1E1E1E");
}
private void dashPanel_MouseLeave(object sender, EventArgs e)
{
dashPanel.BackColor = Color.Transparent;
}
private void sideDashboard_MouseEnter(object sender, EventArgs e)
{
dashPanel.BackColor = System.Drawing.ColorTranslator.FromHtml("#1E1E1E");
}
private void mostActive_MouseEnter(object sender, EventArgs e)
{
dashActive.BackColor = System.Drawing.ColorTranslator.FromHtml("#1E1E1E");
}
private void mostActive_MouseLeave(object sender, EventArgs e)
{
dashActive.BackColor = Color.Transparent;
}
private void mostGainers_MouseEnter(object sender, EventArgs e)
{
dashGain.BackColor = System.Drawing.ColorTranslator.FromHtml("#1E1E1E");
}
private void mostGainers_MouseLeave(object sender, EventArgs e)
{
dashGain.BackColor = Color.Transparent;
}
private void mostLosers_MouseEnter(object sender, EventArgs e)
{
dashLose.BackColor = System.Drawing.ColorTranslator.FromHtml("#1E1E1E");
}
private void mostLosers_MouseLeave(object sender, EventArgs e)
{
dashLose.BackColor = Color.Transparent;
}
private void label2_Click(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Minimized;
}
private void label4_MouseEnter(object sender, EventArgs e)
{
stocksPan.BackColor = System.Drawing.ColorTranslator.FromHtml("#9c9c9c");
}
private void label4_MouseLeave(object sender, EventArgs e)
{
stocksPan.BackColor = Color.Transparent;
}
private void label4_Click(object sender, EventArgs e)
{
var driver = new FirefoxDriver();
driver.Navigate().GoToUrl("https://www.tradingview.com/");
}
private void label6_MouseEnter(object sender, EventArgs e)
{
stocksPanChrome.BackColor = System.Drawing.ColorTranslator.FromHtml("#9c9c9c");
}
private void label6_MouseLeave(object sender, EventArgs e)
{
stocksPanChrome.BackColor = Color.Transparent;
}
private void label6_Click(object sender, EventArgs e)
{
}
private void stockList_TextChanged(object sender, EventArgs e)
{
}
private void sideDashboard_Click(object sender, EventArgs e)
{
activePan.Visible = false;
gainpan.Visible = false;
losPan.Visible = false;
}
private void mostActive_Click(object sender, EventArgs e)
{
activePan.Visible = true;
gainpan.Visible = false;
}
private void mostGainers_Click(object sender, EventArgs e)
{
activePan.Visible = true;
gainpan.Visible = true;
losPan.Visible = false;
}
private void mostLosers_Click(object sender, EventArgs e)
{
activePan.Visible = true;
gainpan.Visible = true;
losPan.Visible = true;
}
private void label11_Click(object sender, EventArgs e)
{
var getTopFive = new FirefoxDriver();
getTopFive.Navigate().GoToUrl("https://www.tradingview.com/");
IList<IWebElement> movies = getTopFive.FindElements(By.CssSelector("[data-symbol='NASDAQ:SIRI']"));
for (int i = 0; i < 1; ++i)
{
activeTextBox.Text = movies[i].Text;
}
}
private void activePan_Paint(object sender, PaintEventArgs e)
{
Label scan = new Label();
scan.Text = "Test";
}
private void pictureBox2_Click(object sender, EventArgs e)
{
var homePage = new FirefoxDriver();
homePage.Navigate().GoToUrl("http://www.vargadevelopments.com");
}
private void label1_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
@SAKyrukov
SAKryukov
What I have tried:
I've tried changing the CssSelector but it either gave me an error or didnt do anything at all, I think im using them the wrong way.