Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
71 views
in Technique[技术] by (71.8m points)

javascript - Getting error while switching to another Frame

Error:Failed: invalid argument: 'id' can not be string (Session info: chrome=88.0.4324.146) Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53' System info: host: 'RADA-HYD-01', ip: '192.168.0.165', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_261' Driver info: driver.version: unknown

Hi can anyone please help me in resolving this issue.

Script:

browser.switchTo().frame('courses-iframe');
    element(by.css("a[href*='Login']")).getText().then(function (Result) {
      console.log(Result);
    });
question from:https://stackoverflow.com/questions/66047237/getting-error-while-switching-to-another-frame

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
    browser.switchTo().frame(element(by.id('courses-iframe'))).then(function(){
        element(by.css("a[href*='Login']")).getText().then(function (Result) {
          console.log(Result);
        });
});

https://www.selenium.dev/selenium/docs/api/javascript/module/selenium-webdriver/lib/webdriver_exports_TargetLocator.html

the switchto frame expcts number,element and null , not string. Where number is iindex like first frame, second frame etc


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...