我正在尝试使用python-selenium.webdriver打开和关闭chrome浏览器,但出现错误,我正在使用ubuntu系统。
我已经下载了chrome浏览器驱动程序,并在代码中提供了相同的路径 我遇到以下错误:
文件“ / home / rupesh / PycharmProjects / Selenium / selenium package / test1.py”,第3行,在 driver = chrome('/ home / rupesh / Downloads / chromedriver_linux64 / chromedriver')
TypeError:“模块”对象不可调用
代码如下:
#include<stdio.h>
#include <stdlib.h>
#define TRUE 1
char tokenize(char *str, char array[10][20])
{
int n = 0, i, j = 0;
for(i = 0; TRUE; i++)//infinite loop until is the end of the string '\0'
{
if(str[i] != ' '){
//position 1, char 1
array[n][j++] = str[i];// if, it is not space, we save the character
}
else{
array[n][j++] = '\0';//end of the first word
n++;// position for next new word
j=0;// start writting char at position 0
}
if(str[i] == '\0')
break;
}
return 0;
}
//removes extra spaces
char* find_word_start(char* str){
/*also removes all extra spaces*/
char *result = (char*) malloc(sizeof(char) *1000);
int c = 0, d = 0;
// no space at beginning
while(str[c] ==' ') {
c++;
}
while(str[c] != '\0'){ // till end of sentence
result[d++] = str[c++]; //take non-space characters
if(str[c]==' ') { // take one space between words
result[d++] = str[c++];
}
while(str[c]==' ') { //
c++;
}
}
result[d-1] = '\0';
//print or return char?
return result;
free(result);
}
int main()
{
char str[]=" Hello world string dudes and dudas ";
//words, and chars in each word
char arr[10][20];
//call the method to tokenize the string
tokenize(find_word_start(str),arr);
int row = sizeof(arr) / sizeof(arr[0]);
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
for(int i = 0;i <= strlen(arr);i++)
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
printf("token[%d]: %s\n", i, arr[i]);
return 0;
}
答案 0 :(得分:1)
驱动程序对象以大写Chrome
开头:
from selenium.webdriver import Chrome
driver = Chrome('/home/rupesh/Downloads/chromedriver_linux64/chromedriver')
答案 1 :(得分:1)
根本原因-1)驱动程序对象开始是用小写的“ chrome”启动的 2)chrome网页驱动程序和chrome版本不同