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.
CodePudding user response:
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
CodePudding user response:
Does the class of the element like this ? 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.