So, this is my problem that everyone with a Linkedin-Account might help me with: I am trying to select some data from Linkedin-Profilepages. Selecting the Name works fine, with this X-Path:
name = driver.find_element_by_xpath('//section[contains(concat(" ",normalize-space(@class)," ")," pv-top-card-v3 ")][contains(concat(" ",normalize-space(@class)," ")," artdeco-card ")][contains(concat(" ",normalize-space(@class)," ")," ember-view ")]//div/following-sibling::*[1]/self::div//div/following-sibling::*[1]/self::div//div[count(preceding-sibling::div)=0]//ul//li[count(preceding-sibling::li)=0][contains(concat(" ",normalize-space(@class)," ")," break-words ")]')
Same for location and current job.
But then it gets tricky. I am trying to select the last education-station, like the last college. It works fine to select it in the chrome developer console, but selenium is not able to find it with the "no such element" error. In the open window of the selenium chromedriver I am still able to find the element with the query.
My query for that is:
school = driver.find_element_by_xpath('//section[@id="education-section"]//ul//li[count(preceding-sibling::li)=0]//div//div//div//a//div/following-sibling::*[1]/self::div//div//h3[contains(concat(" ",normalize-space(@class)," ")," pv-entity__school-name ")]')
I googled around and the only thing I found was about iFrames. As far as I can see, the element is not wrapped in an iFrame. However there is an js-script in the end, that might have something to do with it as I dont really understand what's happening:
function(){var a=n.MessageChannel;"undefined"===typeof a&&"undefined"!==typeof window&&window.postMessage&&window.addEventListener&&!F("Presto")&&(a=function(){var a=window.document.createElement("IFRAME");a.style.display="none";a.src="";window.document.documentElement.appendChild(a);var b=a.contentWindow,a=b.document;a.open();a.write("");a.close();var c="callImmediate"+Math.random(),d="file:"==b.location.protocol?"*":b.location.protocol+"//"+b.location.host,a=(0,_.y)(function(a){if(("*"==d||a.origin==
d)&&a.data==c)this.port1.onmessage()},this);b.addEventListener("message",a,!1);this.port1={};this.port2={postMessage:function(){b.postMessage(c,d)}}});if("undefined"!==typeof a&&!F("Trident")&&!F("MSIE")){var b=new a,c={},d=c;b.port1.onmessage=function(){if(_.l(c.next)){c=c.next;var a=c.za;c.za=null;a()}};return function(a){d.next={za:a};d=d.next;b.port2.postMessage(0)}}return"undefined"!==typeof window.document&&"onreadystatechange"in window.document.createElement("SCRIPT")?function(a){var b=window.document.createElement("SCRIPT");
b.onreadystatechange=function(){b.onreadystatechange=null;b.parentNode.removeChild(b);b=null;a();a=null};
I really don't know if this has anything to do with it, but it might have. I am seriously out of ideas.