When the use case fails, the first response is to check whether the element positioning is correct and the extension that helps the positioning is essential, however, selenium usually opens a clean browser without extension. If the operation procedure is long, you have to manually execute it until that step checks the elements, which takes a long time, so how can we make it open a browser with extensions? Firefox is simple, and a lot of tutorials can be searched as a result, but I haven't seen chrome after searching for an hour. Now I have figured out a solution and recorded it for future reference.
First, go to c: \ Users (User) \ your computer name \ appdata \ Local \ google \ chrome \ User Data \ Default \ extensions, and open extensions, the folder in it is an extension that has been installed (remember to hide the folder on the computer first, otherwise it cannot be found) but the name is a bunch of unordered English letters that I don't understand, my solution is to find the corresponding plug-in version number one by one, find the version number in the chrome extensions option, and then package the plug-in you need: Open chrome settings, and open the extension program in it, select the developer mode. An ID will appear under the plug-in you install. This ID corresponds to the plug-in you want to package and then package the extension program, find the version number folder under the corresponding folder (or you can copy this folder to any place on your computer), that is, the folder inside the ID folder, and click package extension, the corresponding file with the suffix CRX and PEM will appear at the same level of the version number. This CRX file is What we need. After the preparation is complete, check the Code:
Chromeoptions Options = new chromeoptions (); options. addextensions (new file ("C: \ Users \ swang \ appdata \ Local \ google \ chrome \ userdata \ Default \ extensions \ ijaobnmmgonppmablhldddpfmgpklbfh \ 1.6.0 _ 0.crx ")); // Add the extension method to add the path of the CRX File
Driver = new chromedriver (options );
Selenium open Chrome with extension