'VBA - Web Scraping : Instruction migration from IE to EDGE using Selenium

I am trying to migrate the web-scraping instructions from IE to EDGE using Selenium. I noticed that there are substantial differences, so when converting an application instruction into VBE, this is:

ieObj.Document.getElementsByClassName ("login-button bold"). Item.Click

which in IE works great, I couldn't find any matches with Edge -Selenium. The first obstacle consists in the fact that the "ClassName" in Selenium does not exist so it is not possible to instantiate it with the corresponding .FindElement.

Is there anyone who has already solved the problem? How can I do ? Thanks for everything.



Solution 1:[1]

This getElementsByClassName ("login-button bold") will not work, as it contains multiple spaces which means it is combination of 2 classes.

You will have to switch to CSS selector or XPath

However, If you are interested to use CSS selector :

You can try this :

getElementsByCss(".login-button.bold")  

Code:

ieObj.Document.getElementsByCss (".login-button.bold"). Item.Click

Solution 2:[2]

Does the class of the element like this class="login-button bold"? If so, you can try with FindElementsByCss to find the element by the two class names.

Sample code:

driver.FindElementsByCss(".login-button.bold").Item(1).Click

Note: You can change the number in Item() according to your situation. It depends on the position of the element of the class names collection.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 cruisepandey
Solution 2