0

I should start by saying that I'm not a web developer but I have been using Selenium with Python for a few weeks and think I've gotten the basics down.

What I have is a page with a weekly calendar on it. Image as follows:

Calendar

What happens is that you can click on any of the coloured boxes which will bring up a register for a class. It features items that you can click on which bring up new information. The problem I have is that I can't click on the items - or, rather, I don't know how to automate the click. I have automated clicking with Selenium before in other situations.

That looks as follows:

Register

As you can see, the calendar still appears in the background. That is to say, the item we click on doesn't take us to a new page but, I suppose, runs some kind of method which shows the register and populates it with data.

My problem is this: I want to automate the process so that I can click on each of these items then scrape the information. In order to do that I need to be able to automate the clicking for each of the items.

So what have I done? When I've done this before, I've searched through the web html for the relevant part and then grabbed the xPath to the element I needed. But here I can't do that. Why not? Well, firstly, I just can't find that element!

Take a look at this close up of the first column:

enter image description here

It's divided into columns, but then I'd expect the clickable area to be an element within that. As you can see, it's not. Furthermore, the clickable area is just the coloured box itself, but if you look closely you can see the element goes outside of that area. I have gone very close with my mouse cursor to see exactly what's clickable, and it definitely is just the coloured box.

So I've not been able to get the element at all.

I thought I might be able to just find out where we went after I clicked the button, but when I got the link address, it just said it was the same page with no differences.

I appreciate I'm asking quite a broad question here, but the problem is that I don't really know where to start. If someone could give me at least that much, I would be grateful. Like if I could just click on each of these one at a time... I've found where the populated data is so I could grab that without a problem.

Well, here's to hoping.

Edit: I should add that there are some JavaScript items (tag type script, type='text/javascript'). I presume that the answer is in there somewhere, but there is a lot of Javascript and I'm not adept at reading it. It's hard for me to tell what script does what. If I could at least figure out what script runs when I click the item then I think I'd be onto something, but I have no idea. Even that would help me.

2 Answers2

0

I had encountered similar problem when scraping for Instagram followers in mobile view where it was floating box when showing the accounts followers name. The approach I took was identifying the name of floating dialog box and clicking the element in it. It might different in your case of html.

Trying looking at this link. Selenium Scroll inside of popup div

0

Hard to say without the HTML. Maybe try Katalon Recorder (chrome extension) and see if that can detect the xpath for you? It might also be you have to use some kind of javascript to invoke the method for the element

Douglas
  • 13
  • 1
  • 4
  • There is Javascript on the page, but the variable names aren't helpful and it's hard for me to tell which code goes where or does what. And of course I have no idea how to tell what code is running when I click the item in the menu. – TheFaithfulLearner May 01 '20 at 15:56
  • I've never had to track the javascript either, but this looks helpful https://stackoverflow.com/questions/9126723/javascript-execution-tracking-in-chrome-how – Douglas May 01 '20 at 16:05